Upload
jxck-
View
1.271
Download
3
Tags:
Embed Size (px)
DESCRIPTION
introduction to HTTP2 & HPACK based on http2 draft-08 hpack draft-04 at pyfes 2013.11 http://connpass.com/event/4273/
Citation preview
HTTP2.0 & HPACKbased on draft-08
2013/11/30#pyfes
Jack
● id: Jxck● github: Jxck● twitter: jxck_● about: http://jxck.io● blog: http://d.hatena.ne.jp/jxck● Love: music
spec and status
HTTP ?
History of HTTP... HTTP/0.91996/ 5 HTTP/1.0 (RFC 1945)1997/ 1 HTTP/1.1 (RFC 2068)2009/11 SPDY/1...2011/ 9 WebSocket(RFC 6455)2012/ 8 HTTP/2.0 start2012/11 HTTP/2.0 (draft-00)...2013/ 7 HPACK (draft-00)...2013/10 HPACK (draft-04)2013/11 HTTP/2.0 (draft-08)
motivation● Sharing Documents● Over TCP● Text Base Protocol● Stateless
version● HTTP/0.9
● HTTP/1.0
● HTTP/1.1○ Keep-Alive○ Pipelining
HTTP / 1.1
CLIENT SERVER
Req / Res on HTTP/1.1
Text Base Protocol
GET /index.html HTTP/1.1Host: example.orgAccept: text/html
HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 35
<!DOCTYPE html><title>hello</title>
HTTP ?● Simple
○ text base, easy scaling etc○ good for document sharing○ but Good for Now ?
● now “Web” is○ Plat Form (not only document sharing) ○ Ajax, WebSocket…○ tons of JS, CSS, Images...○ PC, Mobile, Tablet, TV, Game …
● needs○ more speed○ more efficiency○ more secure
history and status
HTTP/2.0?
about HTTP2
● httpbis wg at IETF from 2012● motivation
○ update HTTP/1.1● version
○ draft-00 (copy of spdy/3)○ ...○ draft-08 (2013/11/30 current)○ ...○ RFC XXXX (2014 spring? bit.ly/130oZrZ)
SPDY or HTTP2.0 ?
SPDY/3
SPDY/4http2.0-00
http2.0-01
http2.0-08
http2.0SPDY/n ??
specs
● working on github !○ https://github.com/http2/http2-spec
● draft○ http://tools.ietf.org/wg/httpbis/draft-ietf-httpbis-http2/
● current (2013/8/28)
○ http://tools.ietf.org/html/draft-ietf-httpbis-http2-08
● ML○ http://lists.w3.org/Archives/Public/ietf-http-wg/
○ https://www.ietf.org/mailman/listinfo/http-devops
HTTP/2.0 draft-08
● Multiplexing (same as spdy)● Server Push (same idea as spdy)● ALPN / Upgrade● Binary Frames● HPACK
Starting HTTP2.0 (1/2 step)
● “http://”○ Upgrade Header like websocket
● “https://”○ ALPN (application layer protocol negotiation)
○ not NPN like spdy● Known Supported
○ prior knowledge from DNS or so○ may immediately send http2.0 frame
TLS-ALPN (Application Layer protocol negotiation)
Starting HTTP2.0 (2/2 step)
● sending connection header○ make sure peer supports http2.0○ with Magic Octets
505249202a20485454502f322e300d0a0d0a534d0d0a0d0a
PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n
invalid Method PRI
2 new linefor parser
Frame Type
● DATA● HEADERS● PRIORITY● RST_STREAM● SETTINGS● PUSH_PROMISE● PING● GOAWAY● WINDOW_UPDATE● CONTINUATION
HEADERS & DATA frame
CLIENT SERVER
HEADERS(stream_id=1) + END_STREAM + END_HEADERS :method = GET :scheme = https :authority = example.org :path = /index.html accept = text/html
HEADERS(stream_id=1) - END_STREAM + END_HEADERS :status = 200 content-type = text/html content-length = 35
DATA(stream_id=1) + END_STREAM
<!DOCTYPE html><title>hello</title>
Server Push(1)
CLIENT SERVER
HTTP/1.1 200 OKContent-Type: text/htmlContent-Length: 123
{binary data}
PUSH_PROMISE (stream_id=1) + END_PUSH_PROMISE Promised-Stream-ID=2 :method = GET :scheme = https :authority = example.org :path = /a.png
HEADERS (stream_id=1) + END_STREAM + END_HEADERS :method = GET :scheme = https :authority = example.org :path = /index.html accept = text/html
PUSHRequest
Server Push(2)
CLIENT SERVER
Browser Cache
DATA (stream_id=2) + END_STREAM {binary data}
HEADERS (stream_id=2) - END_STREAM + END_HEADERS :status = 200 :path = /a.png content-type = image/png content-length = 123
PUSHRespons
Server Push(2)
CLIENT SERVER
HEADERS (stream_id=1) - END_STREAM + END_HEADERS :status = 200 content-type = text/html content-length = 33
DATA (stream_id=1) + END_STREAM <html> <img src=”a.png”></html>
cache hit !!
Response
HPACK (header compression)
● HTTP Header○ Text Base○ Long Name○ Send multiple time
● SPDY compression○ CRIME
● HPACK○ send diff○ using binary
Static Header Table
Index Header Name Header Value
1 :authority
2 :method GET
3 :method POST
4 :path /
5 :path /index.html
6 :scheme http
7 :scheme https
8 :status 200
9 :status 500
... ... ...
... ... ...
51 refresh
52 retry-after
53 server
54 set-cookie
55 strict-transport-security
56 transfer-encoding
57 user-agent
58 vary
59 via
60 www-authenticate
Huffman Code (Request)sym MSB len hex LSB'a' ( 97) |01000 [5] 8 [5]'b' ( 98) |101111 [6] 2f [6]'c' ( 99) |01001 [5] 9 [5]'d' (100) |110000 [6] 30 [6]'e' (101) |0001 [4] 1 [4]'f' (102) |110001 [6] 31 [6]'g' (103) |110010 [6] 32 [6]'h' (104) |110011 [6] 33 [6]'i' (105) |01010 [5] a [5]'j' (106) |1110001 [7] 71 [7]'k' (107) |1110010 [7] 72 [7]'l' (108) |01011 [5] b [5]'m' (109) |110100 [6] 34 [6]'n' (110) |01100 [5] c [5]'o' (111) |01101 [5] d [5]
Header Representation
● Indexed Header Representation● Literal Header Representation
○ Literal Header without Indexing○ Literal Header with Incremental Indexing
HPACK example (1/2)63byte -> 16byte
1 :authority
2 :method GET
3 :method POST
4 :path /
5 :path /index.html
6 :scheme http
7 :scheme https
:method: GET:scheme: http:path: /:authority: www.example.com
Request Header
Static Table
82 ADD index 287 ADD index 786 ADD index 604 8b db6d 883e 68d1 cb12 25ba 7fADD key at index 4 value “www.example.com”
Decoded Data
Reference Set
1 :authority www.example.com
2 :path /
3 :scheme http
4 :method GET
HPACK example (2/2)87byte -> 8byte
1 :authority
2 :method GET
3 :method POST
4 :path /
5 :path /index.html
6 :scheme http
7 :scheme https
1 cache-control no-cache
2 :authority www.example.com
3 :path /
4 :scheme http
5 :method GET
:method: GET:scheme: http:path: /:authority: www.example.comcache-control: no-cache
Request Header
Static Table
1b 86 63 65 4a 13 98 ffADD key at index 27 value “cache-control: no-cache”
Decoded Data
Reference Set
implementations● nghttp2 C● http2-katanaC#● node-http2 node.js● Mozilla C++● http2-perl Perl● iij-http2 node.js● Akamai GhostC++● Chromium C++● Hasan's GFE C++● Twitter Java● Wireshark C● http2-go Go● http2 Haskell
see: https://github.com/http2/http2-spec/wiki/Implementations
Tools for dev
Tools?
Wireshark & TCP dump
nghttp2
● C implementation library● nghttp
○ client cli tool
● nghttpd○ file server
● nghttpdx○ proxy
web frontend of nghttp2 => http2cat
HTTP2Cat (https://jxck.io/labs/http2cat)
books
● High Performance Browser Networking○ by Ilya Grigorik(Google)
● Translate to Japanese ?○ http://twitter.com/turky/status/406663190768914432
anyone ?
Q & A
thanks :)
END