adding CookieService as a middleware to handle cookies
tried my best to make methods async,Im not so good at handling the lifetimes from the cookie crate,so some of the methods in the service are sync fn
Hey there, thanks for starting! Here's some points:
We want to keep the public API the same, so the builder methods and
CookieStoretrait say the same.The goal is to make an internal type, and
impl<S: Service<Req>> Service<Req> for CookiesService<S>, which adds cookies to the request, and looks at the response and adds new cookies back to the store.Then we can wrap the inner service (is it
HyperService?), and the H3Service, and then each one will no longer need the duplicated cookie management code. Does that make sense?
thank you for giving me points.I tried to hit them but ran into some problems: the new type should be able to wrap a hyperservice or h3service,however I dont know the concrete type of the wrapped, the problem lead to unable to know the response type,which is defined different in those two Services, because of that,I cant call function like Response::headers(),I point to the Service trait defined in hyper project. I figured one solution is to change the Service trait===>type Response->type ResponseBody and make the response the concrete http::Response,but it may be a big change and it is in hyper not reqwest. If you get other solutions,please hit me again!thank you.
the new type should be able to wrap a hyperservice or h3service,however I dont know the concrete type of the wrapped,
That new type can be referenced to tower_http::follow_redirect::FollowRedirect in tower-http.
Hmm, that's say we need a new Service type to unify HyperService and H3Client, then this new Service is wrappered in tower_http::follow_redirect::FollowRedirect.
the new type should be able to wrap a hyperservice or h3service,however I dont know the concrete type of the wrapped,
That
new typecan be referenced totower_http::follow_redirect::FollowRedirectintower-http. Hmm, that's say we need a newServicetype to unifyHyperServiceandH3Client, then this newServiceis wrappered intower_http::follow_redirect::FollowRedirect.
yeah,except now the h3client response === http::Response crate::async_impl::body::ResponseBody and the hyperservice response === http::Response hyper::body::Incoming,if I store a var in the new type ,which is S:Service<Req<Body>>,its abstractive and response is to be defined,not http::Response I must use to unwrap headers. And I just find out I used the wrong Service trait in hyper they look so alike.
I just find out that I could use 'where' to restrict the Response,I have made some changes,somebody please review my code. by the way,I dont like the fact that there are many undefined types in a trait.
@linyihai@seanmonstar do you guys consider this is done by other contributors?If so,please close my pull request.Still,I will keep trying contribute to reqwest.I am curious about this networking thing.
Thanks for you keep doing this thing that I hadn't finished.
do you guys consider this is done by other contributors?
Do you mean https://github.com/seanmonstar/reqwest/pull/2727 ? IMO, I lean to its solution which add the tower-layer to avoid the abstraction of the Response.
Do you mean https://github.com/seanmonstar/reqwest/pull/2727 ? IMO, I lean to its solution which add the
tower-layerto avoid the abstraction of the Response.
yeah,I think so,we are probably doing the same issue of #2693 @seanmonstar