From<http::Response> for Response (#360)
This adds an implementation to convert a `Response` type from the `http` crate to the `async_impl::Response` type. This is the first step to allow us to convert `http::Response` objects to `request::Response` objects This also adds an extension trait for the `http::response::Builder` type. The `http::Response` object does not provide a way to access the "final" url that the response is derived from, so we can't easily provide that in the `From<http::Response>` implementation. For users who are manually constructing `http::Response` objects for use in tests, etc, they can import this extension trait, which adds a `.url()` builder method that will allow them to pass a `Url`, which we then convert to our newtype'd Url and add to the `http::Response`'s `extensions`. Then, when converting from `http::Response` to `async_impl::Response` we can pull that value out of the `extensions` and use it to construct the `async_impl::Response` Closes #333
This commit is contained in:
committed by
Sean McArthur
parent
22fa725f48
commit
4857a5917d
@@ -500,7 +500,7 @@ impl ClientHandle {
|
||||
}
|
||||
};
|
||||
res.map(|res| {
|
||||
response::new(res, self.timeout.0, KeepCoreThreadAlive(self.inner.clone()))
|
||||
response::new(res, self.timeout.0, KeepCoreThreadAlive(Some(self.inner.clone())))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -517,4 +517,10 @@ impl Default for Timeout {
|
||||
|
||||
// pub(crate)
|
||||
|
||||
pub struct KeepCoreThreadAlive(Arc<InnerClientHandle>);
|
||||
pub struct KeepCoreThreadAlive(Option<Arc<InnerClientHandle>>);
|
||||
|
||||
impl KeepCoreThreadAlive {
|
||||
pub(crate) fn empty() -> KeepCoreThreadAlive {
|
||||
KeepCoreThreadAlive(None)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user