Introduction
Definition
HTTP is a protocol for fetching resources from the server. It is the foundation for any data exchange on the Web
Client-Server Protocol
HTTP is a client-server protocol, which means a HTTP request is always sent by the user-agent, which is usually our Web browser
Stateless, but not sessionless
The server treat each request independently, which means the server won’t know if the packet is sent by the same connection
However, we can add HTTP Cookies in HTTP headers, which is an extension of HTTP protocol. The server will maintain the knowledge of cookies, and when the request come in, it will match the cookies with certain user
This way, it allows us to use stateful session
Connection
To establish HTTP connection
- Handshake to create TCP connection
- Handshake to enable TLS
- HTTP request be packed in application layer
- TLS encrypt the information and send to transport layer
- Transport layer transport frames with TCP connection
Component of HTTP
Client: User-Agent
User-agent is any tool that acts on behalf of user. This role primarily performed by Web browser
Web Server
Web server responds to client’s requests. A server appear as only one machine virtually, but it may actually be a collection of servers balancing the load
A server can also host several web server, the Host header in HTTP request will help the server know which Web is client requesting