HTTP - Hypertext Transfer Protocol

This article describes what Hypertext Transfer Protocol or HTTP is all about.
HTTP - Hypertext Transfer Protocol
HTTP stands for Hypertext Transfer Protocol but before starting with HTTP, let us see first what a Protocol actually is.

Protocol defines how computers communicate with each other. A protocol is a set of rules and procedures that computers must follow in order to receive and transmit messages. Most common protocols in use today are HTTP, SMTP, FTP, IMAP, POP3, etc.

Introduction to Hypertext Transfer Protocol (HTTP)

Definition of HTTP:
Since a protocol is set of rules and procedures for communication on a network and since HTTP is a protocol – HTTP in itself is a set of rules and procedures used to communicate over the World Wide Web.

World Wide Web Consortium (W3C) and the Internet Engineering Task Force (IETF) coordinated HTTP development. It's initial purpose was to provide a way to retrieve and publish HTML documents. HTTP protocol comes under application layer (Layer 5) of the TCP/IP model. HTTP Clients make requests to the HTTP protocol and the concerned HTTP server handles these requests. The clients making requests to the web server are referred to as user agents. Typical clients are web browsers, search engine spiders, web enabled applications, etc.

HTTP Clients & Servers Communication

HTTP clients such as web browsers connect to a HTTP server that generally runs on port 80. The HTTP server in turn interprets the request, processes it and responds back to the HTTP client if the need be.

Typical Contents of a HTTP Request Message are -
  • Request line
  • HTTP Headers
  • Empty line
  • Optional message body
HTTP Client Request Methods
  • HEAD
    This method asks information from the server just as the GET method would do, the basic difference is that HEAD method response doesn’t contain a response body.
  • GET
    This method requests a resource from the web server. GET method is one of the most commonly used methods on the web today.
  • POST
    The POST method submits data to the web server for processing. We can experience the POST method while submitting web forms.
  • PUT
    Uploads a specified resource to the HTTP server.
  • DELETE
    Deletes the specified resource from the web server.
  • TRACE
    This method echoes back the received request so the HTTP client can see what intermediate servers are adding or changing in the request.
  • OPTIONS
    This method helps determine the server functionality like determining which methods the web server supports.
  • CONNECT
    The connect method converts the request connection to a transparent TCP/IP tunnel. This helps in facilitating Secure Socket Layer (SSL) communication (HTTPS) through an unencrypted HTTP proxy.

HTTP Response Status Codes

HTTP Response is originated at the web server; it means it is a reply, result or an answer to the client request. The following is a list of web server response codes -

1xx - Informational
  • 100 - Continue
  • 101 - Switching protocols
  • 102 - Processing (WebDAV)
2xx - Success
  • 200 - Ok
  • 201 - Created
  • 202 - Accepted
  • 203 - Non-Authoritative Information
  • 204 - No Content
  • 205 - Reset Content
  • 206 - Partial Content
  • 207 - Multi-Status (WebDAV)
3xx - Redirection
  • 300 - Multiple Choices
  • 301 - Moved Permanently
  • 302 - Not found
  • 303 - See Other
  • 304 - Not Modified
  • 305 - Use Proxy
  • 306 - Switch Proxy
  • 307 - Temporary Redirect
4xx - Client-side Error
  • 400 - Bad Request
  • 401 - Unauthorized
  • 402 - Payment Required
  • 403 - Forbidden
  • 404 - Not Found
  • 405 - Method Not Allowed
  • 406 - Not Acceptable
  • 407 - Proxy Authentication Required
  • 408 - Request Timeout
  • 409 - Conflict
  • 410 - Gone
  • 411 - Length Required
  • 412 - Precondition Failed
  • 413 - Request Entity Too Large
  • 414 - Request-URI Too Long
  • 415 - Unsupported Media Type
  • 416 - Requested Range not satisfiable
  • 417 - Expectation Failed
  • 422 - Unprocessable Entity (WebDAV)
  • 423 - Locked (WebDAV)
  • 424 - Failed Dependency (WebDAV)
  • 425 - Unordered Collection
  • 426 - Upgrade Required
  • 449 - Retry With
5xx - Server-side Error
  • 500 - Internal Server Error
  • 501 - Not Implemented
  • 502 - Bad Gateway
  • 503 - Service Unavailable
  • 504 - Gateway Timeout
  • 505 - HTTP Version Not Supported
  • 506 - Variant Also Negotiates
  • 507 - Insufficient Storage (WebDAV)
  • 509 - Bandwidth Limit Exceeded
  • 510 - Not Extended


A Simple HTTP Communication Scenario

1. HTTP Client makes a connection and sends a request method to the web server.



2. The HTTP server processes the client's request, while the client waits for the server’s response.



3. The web server responds with the status code and data (if available) and closes the connection.


By Amol Vyavhare
Published: 10/30/2007
 
Use the feedback form below to submit your comments.
Your Comments:
Your Name:
Use the form below to email this article to your friends.
Recipient Email Address:
 Separate multiple email addresses by ;
Your Name:
Your Email Address: