The web is a collection of request-response cycles that flow between the client and the server
General Overview
Here we have the browser/client on the left and the server on the right. If the user wants to access data or visit a website say: google.com, the client sends an HTTP request to the server. The server on the other side processes the request and sends it back to the client.Before the client asks for the given information, the client and the server have to be connected, this is taken care of by the internet using a combination of wired/wireless connections and a set of protocols.
What is a client
A client is a piece of hardware/software that accesses a service made available by a server. Generally, clients are web browsers like chrome, or can also be API’s making requests to another server.What is a server
In computing, a server is a piece of computer hardware or software that provides functionality for other programs or devices, called clients. servers can provide various functionalities, often called "services", such as sharing data or resources among multiple clients or performing computation for a client.What is a HTTP request
An HTTP request is a request to a server in the form of a request message which includes the following format:The START LINE holds three 3 values i.e the METHOD, URI, HTTP Version:-
There are 5 types of HTTP methods
- GET => Returns the content of the specified document.
- HEAD => Returns the header information for the specific document.
- POST => Executes the specific document, using the enclosed data.
- PUT => Replace the specified document with the enclosed data.
- DELETE => Delete the specified document.
Among the methods given above, GET and POST are most frequently used. The URI(uniform resource Identifier) is basically a set of readable characters used to locate a given document in a server
The headers on the other hand, are key-value pairs that hold information such as rules to be followed, i.e the address of the server eg:www.facebook.com, or the MIME type(it's basically a label used to identify a type of data.), or what language should it accept its data, etc
What is an HTTP response
HTTP Response is the packet of information sent by the Server to the Client in response to an earlier request made by the Client. HTTP Response contains the information requested by the Client
The status line holds 2 values i.e the HTTP version and a 3 digit status code followed by a short textual response of the status code. for example HTTP/1.1 200 OK
The status code begins with 1,2,3,4, or 5. The general meaning is as follows:-
1 => Informational
2=>Success
3 =>Redirecting
4 =>Client Error
5 =>Server error
The response header field basically holds key-value pairs on how to operate. The Response Body filed basically holds the given file that was requested. If the client is a browser, the HTML body is generally an HTML page that the browser can render