hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.58k stars 1.6k forks source link

I hope the code can be modified as follows #3697

Closed lo-ferris closed 4 months ago

lo-ferris commented 4 months ago

https://github.com/hyperium/hyper/blob/master/src/body/incoming.rs

// This is the source code

WeChatae98761c2031281a9fa89685cd9deec8

// Change to

WeChat3021ad1d0b2f38bd1ad30ba25c75a755
seanmonstar commented 4 months ago

This type purposefully does not expose a public constructor.

The recommendation if you feel you need to construct one is to change your function to accept a generic body, and then you can pass some other type with a public constructor.

lo-ferris commented 4 months ago

Great, thank you.

xitep commented 3 months ago

hello, i understand the need to keep the type opaque. I just wanted to give you an example where having a way to construct Incoming would be helpful.

i'm using Client<..., Incoming> to forward incoming requests (essentially, my program is the gateway example.) in addition, i'd also like to send new requests over that same client (to utilize the underlying connection pooling), but can't since i'm not able to construct requests matching the type Request<Incoming>.