hyper icon indicating copy to clipboard operation
hyper copied to clipboard

fix(client): Do not strip `path` and `scheme` components from URIs for HTTP/2 Extended CONNECT requests

Open bdbai opened this issue 2 years ago • 2 comments

As per RFC 8441:

On requests that contain the :protocol pseudo-header field, the :scheme and :path pseudo-header fields of the target URI (see Section 5) MUST also be included.

I was trying to implement WebSocket handshake based on HTTP/2 Extended CONNECT. The current implementation crafted a request which was considered invalid by the server (HAProxy 2.8):

image

Compared to the example illustrated in RFC 8441, the pseudo headers :scheme and :path were missing.

After the fix, the client could successfully establish a WebSocket tunnel to the server.

image

bdbai avatar Jun 09 '23 17:06 bdbai

Hi @nox , can I nudge a little bit for reviewing this PR?👀

bdbai avatar Jul 02 '23 09:07 bdbai

@nox I have added two integrations tests for client CONNECT requests.

@seanmonstar Since the Extended CONNECT requests only apply to h2, I've made a few changes to the helper macro in the integration test so that certain tests will not run in http/1 mode. Please take a look and see if you are okay with this approach. Thanks!

bdbai avatar Jul 07 '23 17:07 bdbai

I'm happy to get this in with the test, thanks so much! Looks like CI noticed a combination of features that fail to compile, so probably a cfg(feature = ...) flag is needed in a new place.

seanmonstar avatar Aug 02 '23 14:08 seanmonstar

@seanmonstar I've updated it with the feature flags. Hopefully it will pass this time.

bdbai avatar Aug 03 '23 08:08 bdbai

Thank you for being patient with us!

seanmonstar avatar Aug 03 '23 17:08 seanmonstar

Shouldn't these changes be reflected in 1.0.0 version? (or perhaps hyper-utils) I'm a bit concerned that some changes may be missed in the newer versions

cc @seanmonstar

DDtKey avatar Aug 07 '23 14:08 DDtKey

Yes, a similar thing could be made a PR to https://github.com/hyperium/hyper-util

seanmonstar avatar Aug 07 '23 17:08 seanmonstar