-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
- Loading branch information
Showing
4 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters