]> Cypherpunks repositories - gostls13.git/commit
net/http: allow Handlers to handle http2 upgrade PRI requests
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 31 Mar 2016 05:11:41 +0000 (22:11 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 31 Mar 2016 06:12:36 +0000 (06:12 +0000)
commita6557a05a03490af3b26f97f9a4ce99c7c773fe5
tree5a31b5b08d2bb9b424f6b3c31416ec1773fb30b5
parent0026cb788b54e3108534992d98b7fec0cf96de17
net/http: allow Handlers to handle http2 upgrade PRI requests

The http2 spec defines a magic string which initates an http2 session:

    "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"

It was intentionally chosen to kinda look like an HTTP request, but
just different enough to break things not ready for it. This change
makes Go ready for it.

Notably: Go now accepts the request header (the prefix "PRI *
HTTP/2.0\r\n\r\n") as a valid request, even though it doesn't have a
Host header. But we now mark it as "Connection: close" and teach the
Server to never read a second request from the connection once that's
seen. If the http.Handler wants to deal with the upgrade, it has to
hijack the request, read out the "body", compare it against
"SM\r\n\r\n", and then speak http2. One of the new tests demonstrates
that hijacking.

Fixes #14451
Updates #14141 (h2c)

Change-Id: Ib46142f31c55be7d00c56fa2624ec8a232e00c43
Reviewed-on: https://go-review.googlesource.com/21327
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/net/http/readrequest_test.go
src/net/http/request.go
src/net/http/serve_test.go
src/net/http/server.go