feat: add incoming http2 support #33
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a first step towards http2 support (#2 ).
This PR allows incoming http2 requests towards the proxy. This means the proxy server can accept http2 requests, but forwards them as http1 requests towards the target server.
The primary motivation and use case for this PR is that currently vite falls back to http1, when proxy is set, because the proxy server can't handle http2 requests (see vitejs/vite#4184). With this PR, vite can send its own responses as http2 and forward http2 requests to the proxy server. The proxy server forwards the request as http1, but answers the http2 request. I tested this manually.
For full http2 support, the proxy server should forward the request as http2, if possible, but this will require a much larger effort, because the https client currently used can't make h2 requests and the http2 client can't make http1 requests. So we would have to either probe the target server to see if it supports h2 requests and make a http2 connection, for which the API would be slightly different, or evaluate the use of undicis fetch, which can make h2 requests and fall back to http1 transparently. But both approaches are outside the scope of this PR.