Skip to content

Support HTTP2 upgrades with !Send executors #3624

Closed
@JanBerktold

Description

@JanBerktold

Is your feature request related to a problem? Please describe.
I'm looking to utilize hyper with gloomio. It already works with either HTTP1 or HTTP2 but does not support upgrades between them.

I've hacked up a dirty example that works (but breaks Send executors) which can be fetched here: JanBerktold/hyper-util@136a2fe

➜  hyper-util git:(master) ✗ cargo run --example single_threaded_server --features=server,http1,tokio,http2
➜  hyper-util git:(not-send) curl -vv --http2 --http2-prior-knowledge http://127.0.0.1:8000
*   Trying 127.0.0.1:8000...
* Connected to 127.0.0.1 (127.0.0.1) port 8000 (#0)
* Using HTTP2, server supports multiplexing
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x55dd9b4a1eb0)
> GET / HTTP/2
> Host: 127.0.0.1:8000
> user-agent: curl/7.81.0
> accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 200)!
< HTTP/2 200
< content-type: text/plain
< date: Tue, 09 Apr 2024 20:44:58 GMT
< content-length: 14
<
Hello, world!
* Connection #0 to host 127.0.0.1 left intact

It depends on changes in hyper & HTTP:

  • The main change is in JanBerktold/http@cc1cc35. The Extensions struct requires Send on values (through AnyMap). It stores them as an Any/AnyClone internally and hence can't benefit from automatic Send marking.
  • The change in hyper is straightforward & really just removing Send constraints: JanBerktold@e265150

Now, the main problem AFAICT is that we have to decide for AnyMap to support Send or not with each choice breaking one type of executor. To work around this, I am considering suggesting to add a cargo feature for http to conditionally add the Send constraints.

I am opening this issue for discussion about this option and to brainstorm other potential ones as well as issues that I've missed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-featureCategory: feature. This is adding a new feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions