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

@@ -224,6 +224,16 @@ impl RequestBuilder {
self
}
/// Add a set of Headers to the existing ones on this Request.
///
/// The headers will be merged in to any already set.
pub fn headers(mut self, headers: crate::header::HeaderMap) -> RequestBuilder {
if let Ok(ref mut req) = self.request {
crate::util::replace_headers(req.headers_mut(), headers);
}
self
}
/// Disable CORS on fetching the request.
///
/// # WASM