A Closer Look at HTTP HyperText Transfer Protocol.

14
A Closer Look at HTTP HyperText Transfer Protocol

Transcript of A Closer Look at HTTP HyperText Transfer Protocol.

Page 1: A Closer Look at HTTP HyperText Transfer Protocol.

A Closer Look at HTTP

HyperText Transfer Protocol

Page 2: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look

• World Wide Web Standards– HTTP (HyperText Transfer Protocol) governs

requests and responses between the browser and the webserver application program

– HTML (HyperText Markup Language) governs the structure of the HTML webpage

BrowserWebserverProgram

HTML

HTTP

Page 3: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look

• Sample HTTP Request Line– All text, often only a single line– Keyword<sp>absolute path<sp>HTTP/ version– Keyword is GET for Retrievals

• GET must be capitalized

– Absolute path is URL without http://hostname

GET /report1/home.htm HTTP/1.1

Absolute Path

Page 4: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look

• Sample HTTP Request Header– Although the book only discusses the request-line, if

only the absolute path is give, the request line is supposed to be followed by a header line naming the host.

– So if the host is puka.hawaii.edu, the request-line and header would be (where CRLF is carriage return followed by line feed):

GET /report1/home.htm HTTP/1.1[CRLF]

Host:puka.hawaii.edu[CRLF]

New

Page 5: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• Sample HTTP Response Message

– Header is multiple lines of text– Each ends with [CRLF]

HTTP/1.1 200 OK[CRLF]Date: Tuesday, 20-JAN-1999 18:32:15 GMT[CRLF]Server: name of server software[CRLF]MIME-version: 1.0[CRLF]Content-type: text/plain[CRLF][CRLF]File to be downloaded.

Page 6: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• Sample HTTP Response Message

– 200 is a code for a successful retrieval, followed by the humanly readable code, OK

HTTP/1.1 200 OK[CRLF]Date: Tuesday, 20-JAN-1999 18:32:15 GMT[CRLF]Server: name of server software[CRLF]MIME-version: 1.0[CRLF]Content-type: text/plain[CRLF][CRLF]File to be downloaded.

Page 7: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• Sample HTTP Response Message

– There are other codes, indicating errors, such as 404

– Followed by a humanly readable code, such as, host not found

HTTP/1.1 404 Host not Found[CRLF]Date: Tuesday, 20-JAN-1999 18:32:15 GMT[CRLF]Server: name of server software[CRLF]MIME-version: 1.0[CRLF]Content-type: text/plain[CRLF][CRLF]File to be downloaded.

Page 8: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• Sample HTTP Response Message

– MIME-version and Content-type tell the type of file being retrieved

– For HTML document, text/plain

HTTP/1.1 200 OK[CRLF]Date: Tuesday, 20-JAN-1999 18:32:15 GMT[CRLF]Server: name of server software[CRLF]MIME-version: 1.0[CRLF]Content-type: text/plain[CRLF][CRLF]File to be downloaded.

Page 9: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• HTML Pages Contain Text

– To be displayed

• HTML Pages Contain Tags

– Some tags say “place a graphic here”, “place a JAVA applet in a box here”, etc.

– For instance, the tag <img src=“big.jpg> says “Get file big.jpg and place it here in the HTML document”

– Graphics, Java programs, etc. are separate files

Page 10: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• Downloading a “page” may require several

downloads– One for the HTML document– One each for the other files it calls for

HTML

Big.jpg

App.java

WebserverUserPC

File Downloads

2

3

1

Page 11: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• Each download requires a separate HTTP

request-response cycle!– So downloading complex webpages may

require many HTTP request-response cycles

HTML

Big.jpg

App.java

WebserverUserPC

HTTPRequest-Response

Cycle 1

2

3

Page 12: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• How Many HTTP messages will be

created to download the three files?– 3 HTTP request-response cycles– 2 HTTP messages per cycle (request and

response)– 6 HTTP messages total

HTML

Big.jpg

App.java

WebserverUserPC

HTTP Request-ResponseCycle 1

2

3

Page 13: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• HTTP is Unreliable

– There is no error detection and correction for transmission errors

– This helps makes HTTP simple, allowing browsers and webserver application programs to be simple and inexpensive

– As we will see later, TCP at the transport layer is reliable, offering error detection and correction

– TCP gives HTTP clean data, so there is no need for HTTP to do error checking

Page 14: A Closer Look at HTTP HyperText Transfer Protocol.

HTTP: A Closer Look• HTTP is Connectionless

– No connection (agreement to communicate) is made between the browser and webserver application before an HTTP message is sent

– Like sending a letter or an E-mail message (connectionless) as compared to taking on the telephone, where a conversation (connection) must be opened, managed, and closed

BrowserWebserverApplication

HTTPRequest