This repository has been archived by the owner on Jul 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proxy (http.Hijacker).Hijack() calls to Handler.responseWriter in och…
…ttp (#648) Fixes #642 Ensure that plugin/ochttp.Handler proxies (http.Hijacker).Hijack() calls to its responseWriter that we captured. Also add tests to ensure that the behavior with the Go standard library is preserved that is: a) HTTP/1.X connections successfully can use (http.Hijacker).Hijack() b) HTTP/2.X connections are incompatible with (http.Hijacker).Hijack() because with HTTP/2.X, multiple requests can be sent on the same connection thus it doesn't make sense to hijack a connection. The standard library also panics and enforces this behavior. Note that both a) and b) are only enforced at runtime, like we do. We don't need to do any work, except solidify and lock this behavior in our tests. As an advantage, we can now successfully use ochttp.Handler with websockets! If the underlying ResponseWriter doesn't implement http.Hijacker, return an error signifying this. This is consensus after offline discussions with @Ramonza and @rakyll, given that other packages might pass in their custom response writers not just net/http. Also make the initial Hijacker tests integration tests and spell out the actual basic testing in an added and small unit test.
- Loading branch information
Showing
2 changed files
with
171 additions
and
1 deletion.
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