What is an HTTP request?
The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers. HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a web site may be the server. As most of us already know, the Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers. HTTP works as a request-response protocol between a client and server: The browser submits a HTTP request to the server; that request is processed by the server, which returns a HTTP response to the client. The response contains status information about the request.
What are the different types of request methods that can be included in an HTTP request?
Four of the most common request methods are
GET
POST
PUT
DELETE
GET:
GET requests generally ask for the resource to be returned unchanged. Sending a request to for the homepage of Twitter would be a GET request.
POST:
POST requests are used to make a submission to the resource. This type of request would typically ask the server to store new information, for example by writing it to a database. Posting a new tweet would be an example of a POST request.
PUT:
PUT requests are used to update a resource. Editing a tweet would be an example of a PUT request.
DELETE:
DELETE requests are used to remove a resource. For example, deleting a tweet would be an example of a DELETE request.
What is an HTTP response?
An HTTP response is what is sent by a server to a client in response to an HTTP request. These responses contain a status code and if the request was successful, the requested resource. An example status code for a successful request would be “200” and an example status code for an unsuccessful request would be “404”. Other common status codes include “300” for redirects and “500” for server errors.
What happens once the client receives the HTTP response back from the server?
Once the client receives the HTTP response, the browser will render the HTTP response body message. This message is either the requested resource (for example, a web page) or display a message relating to status code if the request wasn’t successful.