Chengyu SHEN

Graduate Student in USC

How to understand HTTP?

Mar 13, 2018 / Written by Chengyu

The internet permeates into our life nowadays. Thanks to the appearances of various web-related applications, everyone could visit website conveniently. However, even though the majority of websites starting with http(s), only a few cybercitizens know the meaning of this. In order to get a better understanding of HTTP, this article explain this protocol's mechanism in an easy way.

Definition:


  • HTTP is a well-known protocol defines how messages are transformed, formatted during web communication, and how web servers and browsers to implement / response those web request.
  • HTTP is a comprehensive protocol defines both Request & Response, in which your computer send a request for a file with specific context to the server, and the server return the corresponding file in the response

How the server and client communicate?

The system architecture of HTTP is a client-server architecture, in which the client knows the identity of server but the server doesn’t have any information of client. In other word, the server can merely response the client’s request after it sent it, and we called it as “Stateless”. Even though the browser may use cookie or the website may use session, the HTTP itself is stateless and it doesn’t remember the state of client.
HTTP requires clients and servers to use text messages for communication. The general format of this text message is like this:

  HTTP Message Format  




Specifically, we could separate the text message into client-side and server-side respectively:

  HTTP Request Format  


The request line has rigid format: method request-URI HTTP version
e.g.: request line: GET /test.html HTTP/1.1
The request header specify header attributes with header-name
e.g.:
HOST: jwssdwed.github.io
ACCEPT: image/gif
ACCEPT-Language: en, cn
For the detailed information, you can visit: HTTP_header_wiki

The status code contains protocol version and HTTP status code:
e.g. HTTP/1.1 200 OK
Detailed information about status code: Status_Code
And the response header performs similarly to the request header.

  HTTP Request Format  

The returned html context will be encapsulated in the body part in response message. And the browser, like Google Chrome, parses those information and renders in the browser.