Skip to main content

01 HTTP

What is HTTP

HTTP is a protocol for communicating between a web browser and a web server.

  • based on TCP/IP
  • uses port 80(HTTP) or 443(HTTPS)

HTTP/0.9

HTTP/0.9

  • only GET method
  • no headers
  • resopnse had to be HTML
request
GET /index.html
response
(response body)
(connection closed)

HTTP/1.0

  • multi response formats (images, video files, plain text...)
  • more methods (POST, HEAD)
  • add request/response headers
  • add status codes
  • character set support
  • authorization
  • caching
  • content encoding
request
GET / HTTP/1.0
Host: cs.fyi
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5)
Accept: */*
response
HTTP/1.0 200 OK
Content-Type: text/plain
Content-Length: 137582
Expires: Thu, 05 Dec 1997 16:00:00 GMT
Last-Modified: Wed, 5 August 1996 15:55:28 GMT
Server: Apache 0.84

(response body)
(connection closed)

Three-way handshake

  • SYN - client sends SYN
  • SYN/ACK - server sends SYN/ACK
  • ACK - client sends ACK

three-way handshake

tip

Connection: keep-alive

keep the connection open for multiple requests

HTTP/1.1

  • add PUT, PATCH, OPTIONS, DELETE
  • hostname identification
  • persistent connections
  • pipelining (Content-Length / chunked encoding)
  • chunked transfer
  • digest and proxy authentication
  • caching
  • byte ranges
  • character sets
  • language negotiation
  • client cookies
  • enhanced compression support
  • new status codes

HTTP/1.1 vs HTTP/1.0

HTTP/1.1 RFC

enhancements

  • use of spritesheets
  • encoded images in CSS
  • single humungous CSS/Javascript files
  • domain sharding

SPDY

decrease latency to improve web performance

  • multiplexing
  • compression
  • prioritization
  • security

HTTP/2

  • binary protocol
  • multiplexing
  • header compression
  • server push
  • request prioritization
  • security