Properties
An HTTP request consists of the following:
- Method -> GET, POST, PUT, DELETE, PATCH, OPTION
- PATH -> domain.tld/path?pathwith=parameters
- Protocol -> HTTP/1.1, HTTP/2
- Headers ->
- Body -> Payload
Note
One server with one IP can host multiple websites. Therefore, in Host the requestor provides the domain name and not the IP address directly.
An HTTP response consists of the following:
- Protocol
- Code -> 200, 404, 503, etc. status codes
- Code Text -> Ok, Not Found, Internal server error, etc., the description of the above codes
- It got removed in HTTP/2
- Headers
- Body
HTTP/1.1 response
HTTP/2 response
HTTP/1.0
- New 59.29 TCP connection with each request -> Initially, keeping a connection open was costly.
- Slow
- Buffering (transfer-encoding: chunked didn't exist)
- No multi-homed websites (HOST header) -> Vercel.com hosting multiple websites would not have worked.
HTTP/1.1
- Persisted TCP Connection
- Low Latency & Low CPU Usage
- Streaming with Chunked transfer
- Pipelining (disabled by default) -> Due to ordering requirements like HTML needs to come first, then images.
HTTP/2
- SPDY
- Compression
- Multiplexing
- Server Push
- Secure by default
- Protocol Negotiation during 59.30 TLS (NPN/ALP)
- It needs a secure connection. It is not backward compatible.
We will learn more on HTTP/2.