wasm: add url function to wasm response (#777)

Adds the url function to wasm::Response
This commit is contained in:
Paolo Barbolini
2020-01-09 22:43:08 +01:00
committed by Sean McArthur
parent 50c33a932e
commit fd88e0c648
2 changed files with 16 additions and 2 deletions

View File

@@ -3,19 +3,24 @@ use std::fmt;
use bytes::Bytes;
use js_sys::Uint8Array;
use http::{HeaderMap, StatusCode};
use url::Url;
/// A Response to a submitted `Request`.
pub struct Response {
http: http::Response<web_sys::Response>,
// Boxed to save space (11 words to 1 word), and it's not accessed
// frequently internally.
url: Box<Url>,
}
impl Response {
pub(super) fn new(
res: http::Response<web_sys::Response>,
//url: Url,
url: Url,
) -> Response {
Response {
http: res,
url: Box::new(url),
}
}
@@ -37,6 +42,12 @@ impl Response {
self.http.headers_mut()
}
/// Get the final `Url` of this `Response`.
#[inline]
pub fn url(&self) -> &Url {
&self.url
}
/* It might not be possible to detect this in JS?
/// Get the HTTP `Version` of this `Response`.
#[inline]