Hyper Text Transfer Protocol is a communication protocol which works with response and request. By sending HTTP request and receiving HTTP response help to create communication between client browsers and servers.
It is easy to understand which result occurs in progress according to status codes. There are several HTTP Status Codes such as ; 1XX, 2XX, 3XX, 4XX, 5XX. The status code which starts with number 1 gives information; the ones that starts with number 2 specify successful states. On the other hand codes which start with number 4 explain a browser error and the codes starting with 5 explain server error.
I would like to explain more clearly how it works step by step.
First of all, browser sends a request to the web. HTTP utilizes specific request methods in order to perform various tasks.
GET method is used for retrieving info from server using given url.
HEAD method is also used to retrieve info but without body content.
POST method is used to post(send) a data to the server, for instance uploading files.
PUT method is used to update whole data in a resource.
PATCH method is used to update part of a resource.
While PUT changes state totally , PATH does it partially. For instance, when we have data consists of name, surname, birth date ; PUT method runs on total data but PATH method changes selected part of it.
DELETE method is used to get rid of the resource.
After a server receives the request, it runs the application to respond. Response returns with a specific status code. Status codes are the numbers which specify result of requests such as ;
201- The request succeeded , new resource is created.
304- Not modified,the website you’re requesting hasn’t been updated since the last time you accessed it.
404- Not Found, server could not find resource which has not recognized URL.
504- Gateway Timeout , when server acts like gateway and dont get response in that exact time.
In the request of a HTML page case, response will be a HTML file. If the browser requests data ,the server gives response with XML or JSON types of data.
The request-response relationship is completed with the data response returned from the server with the status code.