You are on page 1of 36

http2

, ,
http.//daniel.haxx.se/http2/


1........................................................................................................................................................................... 4
1.1....................................................................................................................................................................... 4
1.2.!............................................................................................................................................................. 4
1.3............................................................................................................................................................... 4
1.4. ........................................................................................................................................... 4
2.HTTP ................................................................................................................................................................ 6
2.1.HTTP 1.1 ............................................................................................................................................... 6
2.2. ........................................................................................................................................................... 6
2.3. TCP......................................................................................................... 6
2.4. ........................................................................................................... 7
2.5. .............................................................................................................................................. 7
2.6. ......................................................................................................................... 8
3., .......................................................................................... 9
3.1. ........................................................................................................................................... 9
3.2......................................................................................................................................................... 9
3.3....................................................................................................................................................... 9
3.4.............................................................................................................................................................. 10
4. HTTP.................................................................................................................................................... 12
4.1.IETF HTTPbis................................................................................................................... 12
4.1.1. bis........................................................................................................................................... 13
4.2.http2 SPDY................................................................................................................................... 13
5. http2....................................................................................................................................................... 14
5.1.http2 URI ............................................................................................................ 14
5.2.http2 https://.............................................................................................................................................. 15
5.3.http2 TLS.................................................................................................................. 15
5.4.http2 http://................................................................................................................................................ 16
6. http2.......................................................................................................................................................... 17
6.1. ....................................................................................................................................... 17
6.2. ........................................................................................................................................... 17
6.3. ................................................................................................................. 18
6.4. ......................................................................................................................... 19
6.5. ......................................................................................................................................... 19
6.5.1. ................................................................................................................ 20
6.6.Reset () .......................................................................................................................... 20
6.7.Server push ( )................................................................................................................... 20
6.8. ..................................................................................................................................... 21
7................................................................................................................................................................ 21
7.1. ............................................................................................................................ 21
7.1.1. TLS.................................................................................................................... 22
7.2......................................................................................................................................................... 22
8. http2.................................................................................................................................................................... 23
8.1. http2 ?................................................................................................. 23
8.2. http2 -?.................................................................................................. 23
8.3.http2 ............................................................................................................................................ 24
8.3.1. ............................................................................................................... 24

8.4. http2................................................................................................................................ 25
8.4.1. Google.............................................................................25
8.4.2. ...................................................................................25
8.4.3. ..................................................................25
8.4.4. TLS ...............................................................................26
8.4.5. ASCII- ......................................................................................................... 26
8.4.6. , HTTP/1.1.......................................................................................................... 26
8.4.7. .......................................................................27
8.4.8. HTTP/1.1..........................................................................27
8.5. http2 ?............................................................................................... 27
9.http2 Firefox............................................................................................................................................................. 29
9.1. , ........................................................................................................ 29
9.2. TLS.......................................................................................................................................................... 29
9.3.!........................................................................................................................................................ 29
9.4. HTTP/2................................................................................................................................. 30
10.http2 Chromium................................................................................................................................................... 31
10.1. , ...................................................................................................... 31
10.2. TLS....................................................................................................................................................... 31
10.3. HTTP/2.............................................................................................................................. 31
11.http2 curl................................................................................................................................................................ 32
11.1. HTTP 1.x................................................................................................................................. 32
11.2. ,............................................................................................................. 32
11.3.TLS ............................................................................................................................ 32
11.4. ..................................................................................................... 32
11.5. libcurl................................................................................................................................................... 32
12. http2.............................................................................................................................................................. 34
13. ............................................................................................................................................. 35
14......................................................................................................................................................... 36

1.
, http2 .
,
2014 ,
.
http2
IESG 18 2015 . draft171, RFC.
, .
.
1.10, 18 2015.

1.1.
Mozilla.
.
, , curl libcurl.
IETF HTTPbis
HTTP 1.1, ,
http2.

Email:
Twitter:
Web:
Blog:

daniel@haxx.se
@bagder
daniel.haxx.se
daniel.haxx.se/blog

1.2. !
, , ,

. , ! ,
.
http://daniel.haxx.se/http2

1.3.
Creative Commons
Attribution 4.0: http://creativecommons.org/licenses/by/4.0/

1.4.
25 2014 .
1

http://tools.ietf.org/html/draft-ietf-httpbis-http2-17

:
1.10:

1:

4.1: 2014

1.4:

14: ,

2.4: HTTP

6.3:

6.5.1: HPACK 12- .

1.9: 11 2015

HTTP/2 draft-17 HPACK draft-11

10. http2 Chromium ( )

30

8.5:

8.3: internet explorer

8.3.1:

8.4.3: , TLS

1.8: 15 2015

, pdf

draft-16 hpack-10

URL

8.4

IETF

2. HTTP
HTTP 1.1 , .
,
. ,
- HTTP, - .

2.1. HTTP 1.1


HTTP , , ,
, , . HTTP 1.0
RFC 1945 60 , 1996. RFC 2616,
HTTP 1.1, 1999
176 . , IETF
,
( RFC 7230 ).
, HTTP 1.1 ,
.

2.2.
HTTP 1.1, ,
, ,
, , ,
, . ,
,
,
.
,
. HTTP (HTTP
pipelining) .

2.3. TCP
HTTP 1.1 ,
, TCP. HTTP-
- ,
.
, ,
, TCP ,
TCP, , .
TCP ,
,
.

2.4.


, .
,
1,9 , ,
, .
, .
, , ,
.

1900K
transfer size
100 objects
77 objects
725K
transfer size
2011-2015
httparchive.org

2.5.
HTTP 1.1
, - ,

HTTP
-

.
,

1:
(RTT)

, .
, ,
-,
.
, ,
, -, ,
.

2.6.
HTTP ,
.
. , :
, ,
.


,
,

, , ,


, .


,


. .
, 2015 , -
HTTP .
-
Firefox 2643542.

https://bugzilla.mozilla.org/show_bug.cgi?id=264354

3. ,
, ,
. ,
.

3.1.
,


.
javascript CSS

.

.


HTTP 1.1,
.
, ,
.
, , , ,
.

3.2.

, data URL, CSS .
, .
.icon1 {
background: url(data:image/png;base64,<data>) no-repeat;
}
.icon2 {
background: url(data:image/png;base64,<data>) no-repeat;
}

3.3.
,
javascript .

,
. ,
.
, .
.

3.4.
, ,
, .

. ,
!
HTTP TCP
. ,
,

.
,
6-8 , ,
.
, ,
, HTTP
. 50
100 .
httparchive.org , 300 000 URL'
38(!) TCP- ,
, - .

, cookie, cookie
.
cookie
HTTP-!


- .

4. HTTP
?
...
1. , RTT
2.
3.

4. , , URI
5. IETF HTTPbis

4.1. IETF HTTPbis


(IETF) ,
. .
RFC-, : TCP, DNS, FTP
, HTTP ,
.
IETF ,
.
.
. , -
,
, ,
.
HTTPbis 2007
HTTP 1.1 bis.
HTTP - 2012 .
HTTP 1.1 2014
RFC 7320.
HTTPbis
- 2014 .
IETF RFC .
HTTP
. -
, ,
, , , IETF
...

4.1.1.

bis

HTTPbis, bis ,
3.
IETF . ,
HTTP 1.1.

4.2. http2 SPDY


SPDY4 , Google.
,
,
: -
.
HTTPbis http2, SPDY
. , ,
, .
http2 SPDY/3,
http2 draft-00 .

3
4

http://en.wiktionary.org/wiki/bis#Latin
http://en.wikipedia.org/wiki/SPDY

5. http2
http2? ,
HTTPbis?
, ,
.

HTTP. - ,

TCP.
http:// https://
.
. ,

, -
.
HTTP1 ,
http2-.
,
http2 HTTP 1.1 .
.
, , SPDY
Google. , ,
- , .
. ,
http2, . ,
, http3. http2
.

5.1. http2 URI


, URI ,
http2 .
HTTP 1.x http2 -
http2 .
HTTP 1.1 , Upgrade
, , ,
.
-.
- , SPDY

, , SPDY TLS,
TLS-,
. , NPN
Next Protocol
Negotiation ( ),
,
.

5.2. http2 https://


http2 ,
TLS. SPDY TLS TLS
http2, http2
TLS. ,
, http2 TLS:
Mozilla Firefox Google Chrome.
.
TLS
,
TLS.
- , ,
80 HTTP 1.1,

,
.
TLS

? ,
HTTPbis!
, http2
TLS,
, TLS, TLS.

5.3. http2 TLS


(NPN) ,
SPDY TLS-. ,
IETF ALPN: Application Layer Protocol
Negotiation ( ). ALPN
http2, SPDY -
NPN.
, NPN , ALPN

, , http2 http2-
http2. , NPN SPDY
SPDY http2, NPN, ALPN
.
APLN NPN ,
. ALPN
, , NPN
.

5.4. http2 http://


, HTTP 1.1 http2
Upgrade.
http2, 101 Switching http2
. ,
-, http2-

HTTP1-.
, ,
http2, Internet Explorer
, curl .

6. http2
, , .
. ,
http2.

6.1.
http2 .
. , ,
,
, /ascii, , HTTP 1.1
.
http2 , .
HTTP 1.1
.
,
.
,
, HTTP1 .
, TLS
,
. ,
Wireshark - ,
http2.
, , curl,
http2- Wireshark - .

6.2.
http2
.
,

:
,
,
,

.

http2 , , ,
, HTTP 1.1: DATA () HEADERS

(). .

6.3.
, ,
, , http2,
. .
,
http2-.
http2-
, .

, ,
. , .
.
,
. ( )
, . :

http2 .
.

6.4.
, ,
, .

. ,
,
.
,
,
, ,
, ,
.

6.5.
HTTP . , ,
, ,

. http2 ,
.
HTTP .
, , -,
, . -
.
,
, cookie
. Cookie
,

.
HTTP 1.1
,
TCP-,
, -
ACK , .
.

6.5.1.

HTTPS SPDY BREACH 5 CRIME6.


,
, , .

,
. , HTTPbis .
HPACK7, HTTP/2, ,
, , http2- ,
, .
-, ,

, .
( HPACK) HPAKC ,
,
,
,
(. .
) huffman- .

6.6. Reset ()
HTTP 1.1, HTTP-
Content-Length , .
, (
) TCP-,
TCP-.
.
http2- RST_STREAM,
.

6.7. Server push ( )


. ,
X, ,
Z, .
Z , , .
, ,
,
5
6
7

http://en.wikipedia.org/wiki/BREACH_%28security_exploit%29
http://en.wikipedia.org/wiki/CRIME
http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-07

RST_STREAM, .

6.8.
http2 ,
.
SSH, .
,
,
, .

7.
,
. ,

,
.
http2
. draft-12
.

. ,

. ,
:

7.1.
http2 , TCP-
,
HTTP 1.x . ,
/
.
HTTP-, ,
.
,
.
Alt-Svc8 ( ALTSVC- http2),
. ,
, .
8

http://tools.ietf.org/html/draft-ietf-httpbis-alt-svc-01

,
, .
7.1.1.

TLS

Alt-Svc , http://,
TLS.

TLS :

, HTTP.
TLS
.

7.2.
http2 ,
, . , ,
, - /
- .
draft-12, :
BLOCKED
.
.

8. http2
, http2 ? ?

8.1. http2 ?
http2 .
. SPDY
,
.
http2



..
, ,
.
, , ,
-. :
-.
. ,
. - - , -,
, -
, .

8.2. http2 -?
- -
HTTP 1.1,
.
,

http2 , ,
- http2.

http2. http2,
http2 .
, -
- , ,
HTTP 1.1, http2-, ,
,
.
, , - ,
http2.

8.3. http2

,

.
9 - http2.


http2. ,
, 30
.
Firefox
, Twitter http2. Google
2014 http2 c
, 2014 http2
Chrome. Microsoft
Internet Explorer http2.
curl libcurl http2,
TLS, TLS.
draft-17 ,
draft-14, 14 ,
.
, , ,
, .
8.3.1.

-
. http2 Safari
9

https://github.com/http2/http2-spec/wiki/Implementations

Apple. Apache HTTPD Nginx,


SPDY,
HTTP/2.

8.4. http2
, , ,
, ,
.
:
8.4.1.

Google

,
Google. . IETF
, 30 . ,
Google SPDY,
, ,
, .
Google 10, SPDY NPN
Chrome 2016 HTTP/2.
8.4.2.

- . , http2
HTTP.
, http2 .
, .

, ,
, http2.
REST API HTTP 1.x
http2. , ,
.
8.4.3.

.
,
.

.

10 http://blog.chromium.org/2015/02/hello-http2-goodbye-spdy-http-is_9.html

8.4.4.

TLS

. TLS
,
- TLS. TLS- ,
, ,

, .
. , ,
istlsfastyet.com .
, ATIS Open Web Alliance, ,
11, ,
, ,
.
http2 TLS, .

, TLS

, TLS ,
80- ,
,
, HTTP 1.1 80-
HTTP.
, http2 ,

, HTTPS HTTP
1.1.
8.4.5.

ASCII-

, ,
.
.
,
TLS, HTTP 1.x,
.
8.4.6.

, HTTP/1.1

,
, , SPDY,
11 http://www.atis.org/openweballiance/docs/OWAKickoffSlides051414.pdf ( 26)

(
SPDY?12 SPDY13 )
http2.
. , httpwatch.com 14,
, HTTP/2 .
8.4.7.

, ?

http2
.
8.4.8.

HTTP/1.1

. - HTTP/1.1
HTTP , . ,
Cookie, .
,
, .
Http2, , .

8.5. http2 ?
, ,
.
IPv6,
, ,
. http2 IPv6. , TCP,
HTTP , , TLS . .
.
Google SPDY,

. ,
, SPDY 1%,
, .
- SPDY.
http2, , SPDY, ,
, IETF.
SPDY Google.
12 https://www.usenix.org/system/files/conference/nsdi14/nsdi14-paper-wang_xiao_sophia.pdf and
https://www.usenix.org/sites/default/files/conference/protected-files/nsdi14_slides_wang.pdf
13 http://www.neotys.com/blog/performance-of-spdy-enabled-web-servers/
14 http://blog.httpwatch.com/2015/01/16/a-simple-performance-comparison-of-https-spdy-and-http2/

. Firefox, Chrome
Internet Explorer http2
.
,
http2, Google, Twitter Facebook,
http2 -,
Apache HTTP Server nginx.
H2o15 HTTP- http2
.
-, HAProxy, Squid Varnish
http2.
,
RFC.
2015 , Firefox 35
HTTP/2 , Chrome 40 2%
, Google
. 5% HTTP/2 .
Firefox 35 HTTP/2 9%
.

15 https://github.com/h2o/h2o

9. http2 Firefox
Firefox
http2 .
http2 ,
,
. ,
.

9.1. ,
, Firefox 35, 13 2015 , http2
.

'about:config'

'network.http.spdy.enabled.http2draft'. , true.

9.2. TLS
, Firefox http2 TLS.
http2 Firefox, https:// ,
http2.

9.3. !

2: Firefox , draft-12
, http2.
. , ->, ,

.. - HTTP/2.0 Firefox
X-Firefox-Spdy, , .
, , http2,
http2 HTTP1.x
.

9.4. HTTP/2
Firefox, ,
HTTP/2. SPDY 16

16 https://addons.mozilla.org/en-US/firefox/addon/spdy-indicator/

10. http2 Chromium


Chromium HTTP/2
- . Chrome 40,
27 2015 http2
. ,
.
SPDY .
201517:
Chrome SPDY Chrome 6,
HTTP/2, .
SPDY 2016

10.1. ,
chrome://flags/#enable-spdy4 enable,
.

10.2. TLS
, Chrome http2 TLS.
http2 Crome https:// ,
http2.

10.3. HTTP/2
Chrome, ,
HTTP/2. SPDY 18

17 http://blog.chromium.org/2015/02/hello-http2-goodbye-spdy-http-is_9.html
18 https://chrome.google.com/webstore/detail/spdy-indicator/mpbpobfflnpcgagjijhmgnchggcjblin

11. http2 curl


curl http2, 2013 .
curl, http2, . curl
-,
http2.
Curl nghttp2 19 http2
.

11.1. HTTP 1.x


curl http2-
HTTP 1.x ,
HTTP. curl
HTTP . curl . curl
HTTP 1.x ,
http2-.
, HTTP .

11.2. ,
curl http2 TCP Upgrade.
HTTP- HTTP 2, curl
http2, .

11.3. TLS
curl TLS- TLS, - http2. TLS http2
APLN , , NPN.
curl OpenSSL NSS
ALPN NPN. GnuTLS PolarSSL
ALPN, NPN.

11.4.
curl, http2, ,
TLS, --http2 ( http2). Curl
HTTP/1.1, ,
http2.

11.5. libcurl
https:// http:// URL',
19 https://nghttp2.org/

curl_easy_setopt CURLOPT_HTTP_VERSION
CURL_HTTP_VERSION_2, libcurl http2.
http2, , -
HTTP 1.1.

12. http2
http2.
http2
,
. ,

. ,
?
http2 - HTTP 1,
HTTP 1 http2.
. http3 ?
, - http?

13.
,
, ,
:

HTTPbis : http://lists.w3.org/Archives/Public/ietfhttp-wg/

http2
HTTPbis: http://datatracker.ietf.org/wg/httpbis/

https://wiki.mozilla.org/Networking/http2

http2 curl: http://curl.haxx.se/dev/readme-http2.html

-
http2:
http://http2.github.io/
http://http2.github.io/faq/

http2

Firefox:

FAQ:

14.
, -
(Mark Nottingham) http://www.mnot.net/talks/http2-n-you/
HTTP- http://httparchive.org.
RTT , (Mike Belshe).
,
.
: Kjell Ericson, Bjorn Reese, Linus
Swlas Anthony Bryan. ,
!

: Mikael Olsson, Remi Gacogne,
Benjamin Kircher, saivlis, florin-andrei-tp, Brett Anthoine, Nick Parlante, Matthew King,
Nicolas Peels, Jon Forrest, sbrickey, Marcin Olak

(@truecrux)