Skip to content

How can hyper works on an existing stream, when it used as a http client? #3131

@sunnysab

Description

@sunnysab

Dear developers, hello!

Is your feature request related to a problem? Please describe.
I want to use hyper on an existing stream (may be DuplexStream), and I expect some methods to solve this problem. In my case, only HTTP/1.1 is considered.

Describe the solution you'd like
Actually I copied and adapted some lines from hyper-rustls. I made my own HttpsConnector:

let (mut client, mut server) = tokio::io::duplex(64);
let connector = MyHttpsConnector::new(KiteTlsStream::new(client));
let client: hyper::Client<_, hyper::Body> = hyper::Client::builder()
        .build(connector);

As DuplexStream can not be cloned, my solution failed.

Describe alternatives you've considered
In this way, hyper will be used as a HTTP request generator and response parser. So I wonder that can hyper be used as a pure convertor?

Additional context
This may happen very rarely: I have a client and server (this program), and a web server (named A). The client and the server communicate by gRPC. The server cannot access A directly while the client can. In order to make server to be able to request A for data, I need the client to relay TLS packets to keep communication details private.

         gRPC streaming          socket
Server  ---------------- Client  -------  Web server (A)

steps:

  1. client starts a connection to server using gRPC.
  2. client streams some data to server.
  3. server makes request to web server by gRPC streaming
  4. ...
  5. done

emmmm...What should I do? Thank you!

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