Sunday, May 25, 2014

HTTP Basic

HTTP layered over bidirectional byte stream
– Almost always TCP
● Interaction
– Client sends request to server, followed by
response from server to client
– Requests/responses are encoded in text
● Stateless
– Server maintains no information about past client requests

 HTTP Request

 Request line
– Method
● GET – return URI
● HEAD – return headers only of GET response
● POST – send data to the server (forms, etc.)

– URI
● E.g. http://www.intel-iris.net/index.html with a proxy
● E.g. /index.html if no proxy
– HTTP version

● Request headers
– Authorization – authentication info
– Acceptable document types/encodings
– From – user email
– If-Modified-Since
– Referrer – what caused this page to be requested
– User-Agent – client software

Blank-line
Body

HTTP Request Example

GET /site/nqdinhddt/ HTTP/1.1
Host: sites.google.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0)
Gecko/20100101 Firefox/15.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: [...]
If-Modified-Since: Mon, 24 Sep 2012 22:31:22 GMT

If-None-Match: "1348525882000|#public|0|en|||0"

HTTP Response
● Status-line
– HTTP version
– 3 digit response code
● 1XX – informational
● 2XX – success
– 200 OK
● 3XX – redirection
– 301 Moved Permanently
– 303 Moved Temporarily

304 Not Modified
● 4XX – client error
– 404 Not Found
● 5XX – server error
– 505 HTTP Version Not Supported
Reason phrase
● Headers
– Location – for redirection
– Server – server software
– WWW-Authenticate – request for authentication
– Allow – list of methods supported (get, head, etc)
– Content-Encoding – E.g x-gzip
– Content-Length
– Content-Type
– Expires
– Last-Modified
Blank-line
Body

HTTP/1.1 200 OK
Date: Tue, 27 Mar 2001 03:49:38 GMT
Server: Apache/1.3.14 (Unix)  (Red­Hat/Linux)
mod_ssl/2.7.1 OpenSSL/0.9.5a DAV/1.0.2 PHP/4.0.1pl2
mod_perl/1.24
Last­Modified: Mon, 29 Jan 2001 17:54:18 GMT
ETag: "7a11f­10ed­3a75ae4a"
Accept­Ranges: bytes
Content­Length: 4333
Keep­Alive: timeout=15, max=100
Connection: Keep­Alive
Content­Type: text/html
…..

0 comments:

Post a Comment