You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pretty much what the title says. It would be nice to have a function that makes it easy to create a Request to hand to my various handler functions. As it is, creating a Request using new() requires a HttpRequest from hyper, which requires a NetworkStream... It'd be nice to have a good way to essentially forge a request with no network connection actually involved.
The text was updated successfully, but these errors were encountered:
Request::new() uses the deconstruct() method of the HttpRequest to get the various bits and pieces it needs. Namely, (SocketAddr, Method, Headers, RequestUri, HttpVersion, HttpReader<&'a mut BufReader<&'b mut NetworkStream>>). All of these are trivially constructed except for the HttpReader which contains the body of the request... BUT, it just takes any Read object, not necessarily a BufReader containing a NetworkStream. So we can easily create an in-memory buffer and build a HttpReader around that, and just go from there.
Addendum: It's not quite that straightforward since the actual Request type stores the HttpRequest, for some reason, and a bit of type-foolery has to be done to deal with this. Ownership also gets sticky.
Pretty much what the title says. It would be nice to have a function that makes it easy to create a Request to hand to my various handler functions. As it is, creating a Request using
new()
requires a HttpRequest from hyper, which requires a NetworkStream... It'd be nice to have a good way to essentially forge a request with no network connection actually involved.The text was updated successfully, but these errors were encountered: