The Hypertext Transfer Protocol is the mechanism that facilitates data communication on the web. The communication exchange is made via a client also known as a user agent (web browser, cURL, Telnet) to a web server that hosts the resources. Resources can be documents (HTML, PDF, JSON etc.) which are identified by a URL (uniform resource locator). Resources can be static or dynamic. The HTTP protocol is a two way communication protocol between a client which sends a request and the server which returns a response.
Request & Response
A user may have different objectives while interacting with a particular resource. Imagine all the ways a user can interact with their favorite social media site. The various request methods would accommodate whether a user would like to retrieve, create, update, or delete information for a particular resource. The following lists out the available request methods.
GET: information retrieval from a specified resource
HEAD: a head request is similar to a GET except that the server must not send a message body in the response
POST: submits an entity to the specified resource
PUT: updates the representation of the resource with the payload
DELETE: deletes the specified resource
CONNECT: request that the recipient establish a communication tunnel to the destination
OPTION: request information about the communication options available for the target resource
TRACE: often used a debugging method to echo back the input to the user
HTTP Messages: Header & Body
The content of a request and response is made up of a header and body.
The header is used to provide required information about the request or response. Additional information can be sent along in the header to tweak the operations of the request.
The body is optional for an HTTP message but is the vechicle that carries the requested data (text, files, images, etc).
HTTP Status Codes
Once a request is sent to the web server, the webserver acknowledges the request with a response. A Response will return a status code and headers. The status code is a three digit interger to provide the result of the request. Here is a list of the status codes.
HTTP Protocol is Stateless
The HTTP protocol is stateless, meaning each transaction (request and response) that is made is independent of each other. There may use cases where state is required and cookies and sessions are ways that a web application can handle state.
This outlines the HTTP protocol from a high level regarding the rules that enable a client and web server to communicate with each other.