hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Add option to HttpConnector to enable or disable HttpInfo

Open ho-229 opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. By default hyper will try to get the HttpInfo for each Response even if they are not needed in most cases. The bottom line is that getpeername and getsockname are actually very slow and they can become a performance bottleneck when making a lot of requests

Describe the solution you'd like Just provide an API like client::Builder::set_host

ho-229 avatar May 15 '22 05:05 ho-229

It could be an option on HttpConnector.

seanmonstar avatar May 15 '22 05:05 seanmonstar

hey @seanmonstar, I would like to take this up. Please assign this to me 😄

mnpw avatar May 19 '22 06:05 mnpw

@seanmonstar If no one is currently working on this and if this is still needed, I would like to take it up. Also, I think the relevant code is no longer part of the hyper crate and has instead moved into hyper-util.

I noticed your comment on the linked PR of adding the configuration without introducing a new type. However, based on the below snippet, the Connection trait is implemented for tokio::TcpStream which has no access to Config where the new flag will be stored. Do you have any pointers on getting access to this flag without an outer wrapper object?

https://github.com/hyperium/hyper-util/blob/85aade41a080fc4b40a9a53c818680feed14f138/src/client/connect/http.rs#L342-L366

RajivTS avatar Sep 03 '22 19:09 RajivTS

I think the calls to peer_addr() and local_addr() should be lazy-loaded, then the connection object would cache the results.

ho-229 avatar Jun 11 '23 03:06 ho-229