HTTP - Hypertext Transfer Protocol

Buzzle Staff May 13, 2019
Tap to Read ➤
Hypertext Transfer Protocol is an application protocol which is the basis of communication for accessing the Internet over the World Wide Web.
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.

Background

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

Definition

HTTP is a protocol which contains a set of rules and procedures used to communicate over the World Wide Web.

Clients & Servers Communication

HTTP clients, such as web browsers, connect to its server that generally runs on port 80. This server in turn, interprets the request, processes it, and responds to the client, if needed. Typical contents of a request message are:
  • Request line
  • Headers
  • Empty line
  • Optional message body

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 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, experienced while submitting web forms.
  • PUT - Uploads a specified resource to the server.
  • DELETE - Deletes the specified resource from the web server.
  • TRACE - This method echoes the received request so the client can see what intermediate servers are adding or changing in the request.
  • OPTIONS - This method helps determine the server functionality like determining which method the web server supports.
  • CONNECT - This method converts the request connection to a transparent TCP/IP tunnel. This helps in facilitating Secure Socket Layer (SSL) communication through the unencrypted HTTP proxy.

Response Status Codes

Response is originated at the web server; it means it is a reply, result or an answer to the client request. Here 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

Simple HTTP Communication Scenario

1. The client makes a connection and sends a request method to the web server.
2. The 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.
Write for us