HTTP, which stands for Hypertext Transfer Protocol, is a protocol devised for wired communication and networking over intranets or the World Wide Web, although it was originally developed with the objective of providing a means of publishing and retrieving hypertext pages.
It may be implemented on top of any other protocol, although most commonly Transmission Control Protocol/Internet Protocol (TCP/IP). The World Wide Web Consortium (W3C) collaborated with the Internet Engineering Task Force (IETF) to create a series of Request for Comments (RFCs) to define HTTP.
HTTP functions as a protocol between a client, which makes the HTTP request, and the server, which stores or creates resources such as HTML files and images. When a client is making an HTTP request, such as a web-browser, spider, or any other end-user tool, it is referred to as a user agent.
In turn, the responding server is referred to as the origin server. There may be several intermediaries such as proxies, gateways and tunnels situated in between the user agent and the origin server.
An HTTP client usually initiates a request by establishing a TCP connection to a port on a host, which is generally port 80 by default. The request message sent by a client contains a request line, headers, an empty line, and the optional message body.
The request line and headers and empty line are all required to end with <CR><LF>, which mean "carriage return" and "line feed," respectively. The HTTP server listening on that port waits for the client to send a request message.
After it receives a request, the server sends back a status line along with its own message, which could be the requested file, an error message, or other information. Uniform Resource Identifiers (URI) or Uniform Resource Locators (URL) are used to identify resources to by accessed by HTTP.
There are eight request methods or "verbs" for HTTP which indicate the desired action to be done on the identified resource. The first is "GET," which asks for a representation of a specified resource.
"HEAD" is similar in purpose to "GET," but without the response body, and it is useful when retrieving meta-information included in response headers without having to transport all of the content.
"POST" submits data to the identified resource to be processed in order to create a new resource or update existing resources.
"PUT" uploads a representation of a specified resource, while "DELETE" erases it.
"TRACE" prompts the server to echo back the request sent to it, in order to show the client what intermediate servers are adding or changing in the request.
"OPTIONS" asks for a list of the HTTP methods supported by a server, which may be used in order to check its functionality. Lastly,
"CONNECT" is used to convert the request connection to a transparent TCP/IP tunnel. This last verb is normally used to facilitate SSL-encrypted communication (HTTPS) over an HTTP proxy that is unencrypted. Of these options, it is mandatory for HTTP servers to implement GET, HEAD and OPTIONS.