hyper
hyper copied to clipboard
refactor: Remove Body's Once variant
Signed-off-by: Xuanwo [email protected]
Fix https://github.com/hyperium/hyper/issues/2922
I'm not sure whether I correctly did this, PTAL.
Looks like a couple tests that were using the Default impl will need to be changed to construct a Request manually.
pub fn get(&self, uri: Uri) -> ResponseFuture
where
B: Default,
Client::get needs B: Default, do we need to remove this API? (This will break many code)
No, that method doesn't need to be removed (yet). Just change the tests to use client.request(req).
I'm feeling challenged to migrate tests like http2_detect_conn_eof. Can you give me some help?
In those tests, both request and response depend on hpyer::Body (so does Body::empty()), I can't replace them with http_body_util::Empty<bytes::Bytes> simplely.
Any ideas?
migrate tests like
http2_detect_conn_eof.
I just took a look, and this should be able to fix it:
type Empty = http_body_util::Empty<Bytes>;
let service = service_fn(|_:Request<Body>| future::ok::<_, hyper::Error>(Response::new(Empty::new())));
// ...
let req = Request::builder()
.uri(format!("http://{}/", addr))
.body(Empty::new())
.expect("request builder");
You don't need to change the Request<Body> part of the service_fn, since that's the request that hyper is generating.
Thanks so much for taking it so far! I took care of merge conflicts and finishing out the examples, and completed it in #2922.