Hypertext Transfer Protocol (HTTP)

by admin ~ May 1, 2008

It is a stateless protocol.

It uses the services of TCP on well-known port 80.

HTTP Transaction

HTTP Transaction

Request and Response Messages

HTTP Request and Response

Request and Status Lines

  • Request Type (GET, HEAD, POST, PUT, TRACE, CONNECT, OPTION)

request line status line

  • URL:

URL

  • Version: HTTP 1.1
  • Status Code
  • Status Phrase
Code Phrase
100 Continue
101 Switching
200 OK
201 Created
202 Accepted
204 No Content
301 Moved Permanently
302 Moved Temporarily
304 Not Modified
400 Bad Error
401 Unauthorized
403 Forbidden
404 Not Found
405 Method not allowed
406 Not acceptable(Server Erorr)
500 Internal Server Error
501 Not Implemented
503 Service Unavailable

Header: The header exchanges additional information between the client and the server.

Header

  • General Header: General information about the message and can be present in both request and response.
    • Cache-control
    • Connection
    • Date
    • MIME-version (Multimedia Internet Mail Extension)
    • Upgrade
  • Request Header: Only in request message. Specifies client’s configuration and client’s preferred document format.
    • Accept
    • Accept-charset
    • Accept-encoding
    • Accept-language
    • Authorization
    • From
    • Host
    • If-modified-since
    • If-match
    • If-non-match
    • If-range
    • If-unmodified-since
    • Referrer
    • User-Agent
  • Response Header: Only in Response Message. It specifies server’s configurations and special information about the request.
    • Accept-range
    • Age
    • Public
    • Retry-after
    • Server
  • Entity Header: Gives information about the body of document. Can be both in Request and Response.
    • Allow
    • Content-encoding
    • Content-language
    • Content-length
    • Content-range
    • Content-type
    • Etag
    • Expires
    • Last-modifies
    • Location

example http

Persistent vs. Non-persistent connections

  • Non-persistent connection(HTTP prior to version 1.1 specified a non-persistent connection
      Steps:

    • The client opens a TCP connection.
    • The server sends the response and closes the connection
    • The client reads the data until it encounters an eof(end-of-file) marker, it then closes the connection
  • Persistent Connection: HTTP 1.1 specifies a persistent connection by default. In a persistent connection, the server leaves the connection open for more requests after sending a response. The server can close the connection at the request of the client or if a time-out has been reached. The sender usually sends the length of the data with each response. However there are some occasions when the sender does not know the length of the data. This is the case when a document is created dynamically or actively. In these cases, the server informs the client that the length is not known and closes the connection after sending the data so that the client knows that the end of data has been reached.
Share This Post

Leave a Reply