Skip to content

Support testing of websocket routes #3688

Description

@bjorn3
  • I have looked for existing issues (including closed) about this

Feature Request

Motivation

For regular routes you can test them without listening on any tcp port using router.oneshot(Request::builder()...). For websockets however the WebSocketUpgrade extractor needs the hyper::upgrade::OnUpgrade extension which does not have a public constructor. Adding one has been rejected by hyper in hyperium/hyper#4034.

Proposal

Create an alternative to OnUpgrade that has a public constructor accepting an AsyncRead + AsyncWrite object that can be added as extension to a Request which is checked by WebSocketUpgrade if there is no hyper::upgrade::OnUpgrade extension.

Alternatives

Locally patch hyper to make the OnUpgrade constructor public. This would effectively require vendoring hyper to be able to run in CI and make it impossible to publish the project in question to crates.io.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions