Make headers method on WASM client for compatibility with async_impl (#991)

The replace_headers method had to be moved since the async_impl module
is not compiled while compiling to wasm. This caused the replace_headers
method to be unavailable. fast_random had to be excluded from the wasm
build to prevent dead code warnings in the wasm target.
This commit is contained in:
Jason van den Hurk
2020-08-07 00:07:43 +02:00
committed by GitHub
parent 77d7e452e1
commit 83fa93ccaf
5 changed files with 44 additions and 30 deletions

View File

@@ -228,7 +228,7 @@ impl RequestBuilder {
/// ```
pub fn headers(mut self, headers: crate::header::HeaderMap) -> RequestBuilder {
if let Ok(ref mut req) = self.request {
async_impl::request::replace_headers(req.headers_mut(), headers);
crate::util::replace_headers(req.headers_mut(), headers);
}
self
}
@@ -605,7 +605,7 @@ impl<T> TryFrom<HttpRequest<T>> for Request where T:Into<Body> {
let url = Url::parse(&uri.to_string())
.map_err(crate::error::builder)?;
let mut inner = async_impl::Request::new(method, url);
async_impl::request::replace_headers(inner.headers_mut(), headers);
crate::util::replace_headers(inner.headers_mut(), headers);
Ok(Request {
body: Some(body.into()),
inner,