0% found this document useful (0 votes)
9 views24 pages

HTTP

Uploaded by

Hari Haraan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views24 pages

HTTP

Uploaded by

Hari Haraan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Hypertext Transport Protocol

(HTTP)
• HTTP is based on the request-response
communication model:
– Client sends a request
– Server sends a response
• HTTP is a stateless protocol:
– The protocol does not require the server to
remember anything about the client between
requests.

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP
• Normally implemented over a TCP connection
(80 is standard port number for HTTP)
• Typical browser-server interaction:
– User enters Web address in browser
– Browser uses DNS to locate IP address
– Browser opens TCP connection to server
– Browser sends HTTP request over connection
– Server sends HTTP response to browser over
connection
– Browser displays body of response in the client area
of the browser window

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP
• The information transmitted using HTTP is
often entirely text
• Can use the Internet’s Telnet protocol to
simulate browser request and view server
response

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP

Connect { $ telnet www.example.org 80


Trying 192.0.34.166...
Connected to www.example.com
(192.0.34.166).
Escape character is ’^]’.
Send GET / HTTP/1.1
Request
{ Host: www.example.org

HTTP/1.1 200 OK
Receive
Response { Date: Thu, 09 Oct 2003 20:30:49 GMT

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Structure of the request:
– start line
– header field(s)
– blank line
– optional body

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Structure of the request:
– start line
– header field(s)
– blank line
– optional body

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Start line
– Example: GET / HTTP/1.1
• Three space-separated parts:
– HTTP request method
– Request-URI
– HTTP version

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Start line
– Example: GET / HTTP/1.1
• Three space-separated parts:
– HTTP request method
– Request-URI
– HTTP version
• We will cover 1.1, in which version part of start line
must be exactly as shown

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Start line
– Example: GET / HTTP/1.1
• Three space-separated parts:
– HTTP request method
– Request-URI
– HTTP version

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Uniform Resource Identifier (URI)
– Syntax: scheme : scheme-depend-part
• Ex: In http://www.example.com/
the scheme is http
– Request-URI is the portion of the requested
URI that follows the host name (which is
supplied by the required Host header field)
• Ex: / is Request-URI portion of
http://www.example.com/

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
URI
• URI’s are of two types:
– Uniform Resource Name (URN)
• Can be used to identify resources with unique
names, such as books (which have unique ISBN’s)
• Scheme is urn
– Uniform Resource Locator (URL)
• Specifies location at which a resource can be
found
• In addition to http, some other URL schemes are
https, ftp, mailto, and file

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Start line
– Example: GET / HTTP/1.1
• Three space-separated parts:
– HTTP request method
– Request-URI
– HTTP version

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Common request methods:
– GET
• Used if link is clicked or address typed in browser
• No body in request with GET method
– POST
• Used when submit button is clicked on a form
• Form information contained in body of request
– HEAD
• Requests that only header fields (no body) be
returned in the response

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Structure of the request:
– start line
– header field(s)
– blank line
– optional body

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Header field structure:
– field name : field value
• Syntax
– Field name is not case sensitive
– Field value may continue on multiple lines by
starting continuation lines with white space
– Field values may contain MIME types, quality
values, and wildcard characters (*’s)

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
Multipurpose Internet Mail
Extensions (MIME)
• Convention for specifying content type of a
message
– In HTTP, typically used to specify content type
of the body of the response
• MIME content type syntax:
– top-level type / subtype
• Examples: text/html, image/jpeg

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Quality Values and
Wildcards
• Example header field with quality values:
accept:
text/xml,text/html;q=0.9,
text/plain;q=0.8, image/jpeg,
image/gif;q=0.2,*/*;q=0.1
• Quality value applies to all preceding items
• Higher the value, higher the preference
• Note use of wildcards to specify quality 0.1
for any MIME type not specified earlier

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Request
• Common header fields:
– Host: host name from URL (required)
– User-Agent: type of browser sending request
– Accept: MIME types of acceptable documents
– Connection: value close tells server to close
connection after single request/response
– Content-Type: MIME type of (POST) body, normally
application/x-www-form-urlencoded
– Content-Length: bytes in body
– Referer: URL of document containing link that
supplied URI for this HTTP request

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Response
• Structure of the response:
– status line
– header field(s)
– blank line
– optional body

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Response
• Structure of the response:
– status line
– header field(s)
– blank line
– optional body

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Response
• Status line
– Example: HTTP/1.1 200 OK
• Three space-separated parts:
– HTTP version
– status code
– reason phrase (intended for human use)

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Response
• Status code
– Three-digit number
– First digit is class of the status code:
• 1=Informational
• 2=Success
• 3=Redirection (alternate URL is supplied)
• 4=Client Error
• 5=Server Error
– Other two digits provide additional information

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Response
• Structure of the response:
– status line
– header field(s)
– blank line
– optional body

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0
HTTP Response
• Common header fields:
– Connection, Content-Type, Content-Length
– Date: date and time at which response was generated
(required)
– Location: alternate URI if status is redirection
– Last-Modified: date and time the requested resource
was last modified on the server
– Expires: date and time after which the client’s copy of
the resource will be out-of-date
– ETag: a unique identifier for this version of the
requested resource (changes if resource changes)

Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved. 0-13-185603-0

You might also like