HTTP
Hypertext Transfer Protocol (HTTP) is the mechanism that websites and web services use to communicate with user agents such as browsers.
HTTP is a client-server protocol: HTTP requests are send by a user agent to the server, which will reply with a HTTP response. The server will typically be dealing with many, many user agents at once. HTTP requests and responses are plain text, typically sent over a TCP connection.
A Conversation in HTTP
When visiting this page in a browser, your HTTP request will look something like this:
The first line contains the HTTP method ("GET"), the path at which the request is directed (/glossary/http), and the version of HTTP being used. The next few lines contain HTTP headers: in this case they describe the site being contacted, the browser being used, and what content type is being expected by the browser.
HTTP requests can also contain a body, but since this is a GET request, the browser does not send one. (More on this later.)
The response from the server will look something like:
The first line confirms the version of HTTP being used, and contains the status code ("200") and message ("OK") indicating that the request was successfully filled. There are many potential status codes that the server can issue to indicate the next appropriate action for the browser.
HTTP responses also return headers -- in this case, indicating the content type and length, and the date. The final part of the response contains the body. Here, the server returns HTML describing the web page.
Once the browser receives the response, it will begin rendering the HTML, and will call back to the server to retrieve any linked resources (like images, JavaScript files and stylesheets.)
HTTP Methods
There are nine HTTP methods (or "verbs") -- the most commonly occurring ones are:
| Method | Description |
|---|---|
GET | Retrieves a resource from the server. |
POST | Creates a resource on the server. |
PUT | Creates or updates a new resource on the server. |
DELETE | Deletes a resource on the server. |