Network

What is HTTP with Example?

In this tutorial, we are going to see What is HTTP with Example? The HyperText Transfer Protocol (HTTP) is the most widely used protocol on the Internet since 1990. Version 0.9 was only intended to transfer data on the Internet (in particular Web pages written in HTML. Version 1.0 of the protocol (the most used) allows now to transfer messages with headers describing the content of the message using a MIME type coding.

The purpose of the HTTP protocol is to allow the transfer of files (essentially in HTML format) located thanks to a string called URL between a browser (the client) and a Web server (called httpd on UNIX machines).
 

 

Communication between browser and server

The communication between the browser and the server is done in two steps:
 


Image source: www.seobility.net

 

  • The browser makes an HTTP request
  • The server processes the request and sends an HTTP response

In fact, the communication takes longer if we consider the processing of the request by the server. Since we are only interested in the HTTP protocol, the server-side processing will not be explained in this tutorial. If you are interested in this topic, please refer to the tutorial on CGI processing.
 

 

HTTP request

An HTTP request is a set of lines sent to the server by the browser. It includes :

  • A request line: this is a line specifying the type of document requested, the method that must be applied, and the version of the protocol used. The line includes three elements that must be separated by a space:
    • The method
    • THE URL
    • The protocol version used by the client (usually HTTP/1.0)
  • The header fields of the request: these are a set of optional lines allowing to give additional information about the request and/or the client (browser, operating system, …). Each of these lines is composed of a name qualifying the type of header, followed by a colon (:) and the value of the header
  • The body of the request: this is a set of optional lines that must be separated from the previous lines by an empty line and that allow, for example, the sending of data by a POST command when sending data to the server using a form
Example of HTTP request:
GET http://www.stackhowto.com HTTP/1.0
Accept: text/html
If-Modified-Since: Monday, 22-January-2022 14:37:11 GMT
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 10)

 

 

HTTP response

An HTTP response is a set of lines sent to the browser by the server. It includes :

  • A status line: it is a line specifying the version of the protocol used and the status of the processing of the request using a code and an explanatory text. The line includes three elements that must be separated by a space:
    • The version of the protocol used
    • The status code
    • The code’s meaning
  • The header fields of the response: these are a set of optional lines allowing to give additional information about the response and/or the server. Each of these lines is composed of a name qualifying the type of header, followed by a colon (:) and the value of the header
  • The body of the response: it contains the requested document
Example of HTTP response:
HTTP/1.0 200 OK
Date : Mon, 22 Feb 2022 20:55:59 GMT
Server : Microsoft-IIS/2.0
Content-Type : text/HTML
Content-Length : 1356
Last-Modified : Mon, 22 Feb 2022 20:55:59 GMT

 
mcq-networking-question-answerComputer Network MCQ – Questions and Answers – Part 1Networking MCQs questions with answers to prepare for exams, tests, and certifications. These questions are taken from a real written exam and some parts are…Read More

Leave a Reply

Your email address will not be published. Required fields are marked *