reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Provide custom TCP stream

Open cvengler opened this issue 8 months ago • 3 comments

It would be nice if reqwest would support of providing a custom TCP stream, one that is created and managed by the application that interfaces with reqwest. This could be done with some generic traits, such as requiring AsyncRead + AsyncWrite.

Personally, I would like to use arti with reqwest in order to make HTTP request through the Tor network, but right now it seems that I have to use the lower-level hyper crate for this.

cvengler avatar Apr 08 '25 09:04 cvengler

It's something I'd like to enable somehow, yea. I'd like people to be able to slot in custom connector entirely. Doing so has some outstanding questions though: is the pool part of the connector? is TLS part of the connector? What do we do with client builder options that currently customize those various parts that might get swapped out?

Likely a few more I haven't thought of.

I currently have other things as higher priority, but it'd be fine if others want to explore what some of the answers to those questions are without me.

seanmonstar avatar Apr 08 '25 20:04 seanmonstar

Would a tcp_socket_factory / udp_socket_factory function on ClientBuilder be accepted? We'd need a trait similar to Resolve that can produce a TcpStream / UdpSocket given a source and destination IP.

thomaseizinger avatar Sep 01 '25 07:09 thomaseizinger

It's something I'd like to enable somehow, yea. I'd like people to be able to slot in custom connector entirely. Doing so has some outstanding questions though: is the pool part of the connector? is TLS part of the connector? What do we do with client builder options that currently customize those various parts that might get swapped out?

Would be great to have something like this! My ideal situation would be that the connector is just a bare (TLS) connection, and the connection pool part of reqwest. My use case requires mTLS connections where the private key is not directly accessible by the application.

Daanoz avatar Nov 30 '25 13:11 Daanoz