- only GET
- only HTML format
- TCP close after request
GET /index.html
<html>
<body>Hello World</body>
</html>
- add POST, HEAD
- add HTTP header
- status code
- User-Agent
- Content-Type
- ...
- header must be ASCII, body can be anything (with content type, or MIME type)
Content-Encoding
for can be used for compression
GET / HTTP/1.0
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5)
Accept-Encoding: gzip, deflate
Accept: */*
HTTP/1.0 200 OK
Content-Type: text/plain
Content-Length: 137582
Content-Encoding: gzip
Expires: Thu, 05 Dec 1997 16:00:00 GMT
Last-Modified: Wed, 5 August 1996 15:55:28 GMT
Server: Apache 0.84
<html>
<body>Hello World</body>
</html>
- problem:
- TCP closed by default after each request (nonstandard
Connection: keep-alive
to keep connection)
Connection: keep-alive
by default
Connection: close
explicitly to close TCP connection
- pipelining
- in one connection, client can send multiple request without response
Content-Length
seperate responses in pipelining
- or use
Transfer-Encoding: chunked
for time-comsuming response (only can know content length after it's done)
HTTP/1.1 200 OK
Content-Type: text/plain
Transfer-Encoding: chunked
25
This is the data in the first chunk
1C
and this is the second one
3
con
8
sequence
0
- add
PUT
, PATCH
, HEAD
, OPTIONS
, DELETE
- problem:
- in one connection, server response one after another (Head-of-line blocking)
- uncompressed header (large cookies)
- called frame: HEADERS frame, DATA frame, all can be binary
- multiplexing: both client and server can send request/response without blocking
- stream: data with a stream id out of order. Ability to cancel without close connection
- header can be gzipped
- reduendent header are saved in a table, only need to send table index.
- server push