Top Banner
Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar Internet Programming
32

Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

Jan 02, 2016

Download

Documents

Internet Programming. Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar. H ypertext T ransfer P rotocol - HTTP. Contents. Introduction to HTTP Why is HTTP so popular ? Different evolutions of HTTP. 3.1. HTTP 0.9, HTTP1.0 and HTTP 1.1 - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

Lecture # 1By: Aftab AlamDepartment Of Computer ScienceUniversity Of Peshawar

Internet ProgrammingInternet Programming

Page 2: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

Hypertext Transfer Protocol - HTTPHypertext Transfer Protocol - HTTP

Page 3: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

ContentsContents1. Introduction to HTTP

2. Why is HTTP so popular ?

3. Different evolutions of HTTP.3.1. HTTP 0.9, HTTP1.0 and HTTP 1.1

4. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request 4.1.1. HTTP Client Request Line

4.1.2. HTTP Client Request Header

4.1.3 HTTP Client Request Body

4.2 HTTP 1.1 Server Response4.2.1. HTTP Server Response Line

4.2.2. HTTP Server Response Header

4.2.3 HTTP Server Response Body

Page 4: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

ContentsContents1. INTRODUCTION TO HTTP

2. Why is HTTP so popular ?

3. Different evolutions of HTTP.3.1. HTTP 0.9, HTTP1.0 and HTTP 1.1

4. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request 4.1.1. HTTP Client Request Line

4.1.2. HTTP Client Request Header

4.1.3 HTTP Client Request Body

4.2 HTTP 1.1 Server Response4.2.1. HTTP Server Response Line

4.2.2. HTTP Server Response Header

4.2.3 HTTP Server Response Body

Page 5: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

1.Introduction to HTTP 1.Introduction to HTTP • HTTP stands for Hypertext Transfer

Protocol.

• Used to transfer resources on the WWW.

• These resources could be • HTML files• Image files• Query results etc

Page 6: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

1.Introduction to HTTP (cont’d)1.Introduction to HTTP (cont’d)

• A browser works as an HTTP client because it sends requests to an HTTP server which is called Web server.

• The Web Server then sends responses back to the client.

• The standard and default port for HTTP servers to listen on is 80.

Page 7: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

1.Introduction to HTTP (cont’d)1.Introduction to HTTP (cont’d)

• Three important things about HTTP.• HTTP is connectionless.• HTTP is media independent. (any data)• HTTP is stateless.

Page 8: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

1.Introduction to HTTP (cont’d)1.Introduction to HTTP (cont’d)

Page 9: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

ContentsContents1. Introduction to HTTP

2. WHY IS HTTP SO POPULAR ?

3. Different evolutions of HTTP.3.1. HTTP 0.9, HTTP1.0 and HTTP 1.1

4. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request 4.1.1. HTTP Client Request Line

4.1.2. HTTP Client Request Header

4.1.3 HTTP Client Request Body

4.2 HTTP 1.1 Server Response4.2.1. HTTP Server Response Line

4.2.2. HTTP Server Response Header

4.2.3 HTTP Server Response Body

Page 10: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

2. Why HTTP is so popular?2. Why HTTP is so popular?• It is the data transfer protocol standard

used for the web.

• HTTP is simple and fast.

Page 11: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

ContentsContents1. Introduction to HTTP

2. Why is HTTP so popular ?

3. DIFFERENT EVOLUTIONS OF HTTP.3.1. HTTP 0.9, HTTP1.0 and HTTP 1.1

4. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request 4.1.1. HTTP Client Request Line

4.1.2. HTTP Client Request Header

4.1.3 HTTP Client Request Body

4.2 HTTP 1.1 Server Response4.2.1. HTTP Server Response Line

4.2.2. HTTP Server Response Header

4.2.3 HTTP Server Response Body

Page 12: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

3.Different evolutions of HTTP.3.Different evolutions of HTTP.

• HTTP 0.9

• HTTP 1.0

• HTTP 1.1

Page 13: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

3. Different evolutions of HTTP. (Cont’d)3. Different evolutions of HTTP. (Cont’d)

• HTTP 0.9 defined in 1992.• Basic features:

– Request : Only 1 method supported in the request message (GET).

– Reply : Contains only HTML format.

– Only HTML documents are permitted (no other formats)

– Efficient and adapted when it was created but began quickly limited.

Page 14: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

3. Different evolutions of HTTP. (Cont’d)3. Different evolutions of HTTP. (Cont’d)

• HTTP 1.0– Published in RFC 1945.– Improvements between these 2 versions

• Use the MIME type headers.• Basic Authentication (no encryption).• HTTP version number in the request message.• Introduce metadata

Page 15: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

3. Different evolutions of HTTP. (Cont’d)3. Different evolutions of HTTP. (Cont’d)

• Problems with HTTP 0.9 and HTTP 1.0

– Congestion (traffic jam) and high delay during the communication.

– Size of “get method” only a few thousand bit.

– Not enough security (basic authentication).

Page 16: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

3. Different evolutions of HTTP. (Cont’d)3. Different evolutions of HTTP. (Cont’d)

• Solution HTTP 1.1– Improve performance.

– New methods : • delete, • put, • options,• trace and • connect.

Page 17: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

ContentsContents1. Introduction to HTTP

2. Why is HTTP so popular ?

3. Different evolutions of HTTP.3.1. HTTP 0.9, HTTP1.0 and HTTP 1.1

4. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request 4.1.1. HTTP Client Request Line

4.1.2. HTTP Client Request Header

4.1.3 HTTP Client Request Body

4.2 HTTP 1.1 Server Response4.2.1. HTTP Server Response Line

4.2.2. HTTP Server Response Header

4.2.3 HTTP Server Response Body

Page 18: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request

4.2. HTTP 1.1 Server Response

Page 19: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

ContentsContents1. Introduction to HTTP

2. Why is HTTP so popular ?

3. Different evolutions of HTTP.3.1. HTTP 0.9, HTTP1.0 and HTTP 1.1

4. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request 4.1.1. HTTP Client Request Line

4.1.2. HTTP Client Request Header

4.1.3 HTTP Client Request Body

4.2 HTTP 1.1 Server Response4.2.1. HTTP Server Response Line

4.2.2. HTTP Server Response Header

4.2.3 HTTP Server Response Body

Page 20: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request The HTTP request that the browser sends to

the server contains

4.1.1. HTTP Client Request Line

4.1.2. HTTP Client Request Header4.1.3 HTTP Client Request Body

Page 21: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request

Example:GET/test.com/HTTP 1.1

Accept Language: en-usConnection: Keep-AliveHost: www.test.comReferer: http://test.com/index.php?id=10User-Agent: Mozilla ( Linux 2.0.32 i586)

Page 22: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.1.1. HTTP Client Request LineRequest line consist of three pieces of information.

i. HTTP command known as method o GET, POST, HEAD, PUT, DELETE, TRACE, OPTIONS, CONNECT

ii. Path from the resources that the client is requesting.iii. The version numbers of HTTP (such as HTTP 1.1)

Example

GET/ yahoo.com HTTP/1.1

Page 23: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.1.2. HTTP Client Request Header

HTTP request’s header contains information falls into three

different categories.

i. General Information.Information about either client or server.

ii. Entity Information.Information about the data being sent b/w client and server

iii. Request Information.Request information form the client.

Page 24: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.1.2. HTTP Client Request Header

Example

Accept Language: en-usConnection: Keep-AliveHost: www.test.comReferer: http://test.com/index.php?id=10User-Agent: Mozilla

Page 25: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

• 4.1.3 HTTP Client Request Body

If the post method is used in the HTTP request line, then the http request body contains data that is being send to the server..

For example. HTML form data.

Page 26: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

ContentsContents1. Introduction to HTTP

2. Why is HTTP so popular ?

3. Different evolutions of HTTP.3.1. HTTP 0.9, HTTP1.0 and HTTP 1.1

4. HTTP Protocol Version 1.1

4.1. HTTP 1.1 Client Request 4.1.1. HTTP Client Request Line

4.1.2. HTTP Client Request Header

4.1.3 HTTP Client Request Body

4.2 HTTP 1.1 SERVER RESPONSE4.2.1. HTTP Server Response Line

4.2.2. HTTP Server Response Header

4.2.3 HTTP Server Response Body

Page 27: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.2. HTTP 1.1 Server Response

The HTTP response is sent by the server back to the client and contains the following three things.

4.1.1. HTTP Server Response Line

4.1.2. HTTP Server Response Header

4.1.3 HTTP Server Response Body

Page 28: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.2. HTTP 1.1 Server Response

Example

HTTP 1.1 200 OK (status line)

Date Fri, 8Oct 3009 2009 14:09:03 GMT (General header)

Server : Apache/5.0(Unix) PHP/5.0 (Response Header)

Last modified Fri, 29th Oct 2009 14:09:03 GMT (Entity Header)

Page 29: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.1.1. HTTP Server Response LineExample: HTTP/1.1 200 ok

Contains two bits of information.i. HTTP version number.

ii. HTTP request code Request code that reports the success or failure of the request.

100-199= Request is processed.

200-299=Request is successful.

300-399=Request failed because information has been removed.

400-499=Client Error( Incomplete request or impossible request)

500-599=Server Error( the request is valid but the server is not able to

complete the request)

Page 30: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.1.2 HTTP Server Response HeaderServer response header consist of the following three types of information

i General Information.Information about either client or server.

ii Entity Information.Information about the data being sent b/w client and server

iii. Response Information.

Response information sending back to the client

Page 31: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

4. HTTP Protocol Version 1.14. HTTP Protocol Version 1.1

4.2.3 HTTP Server Response Body

If the request is successful, the HTTP response body contains the HTML code.

If unsuccessful the a failure code is sent.

Page 32: Lecture # 1 By: Aftab Alam Department Of Computer Science University Of Peshawar

5. References.5. References.

RFC 2616

http://www.rfc-ditor.org/rfc/rfc2616.txt