wasm: add url function to wasm response (#777)
Adds the url function to wasm::Response
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							50c33a932e
						
					
				
				
					commit
					fd88e0c648
				
			| @@ -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] | ||||
|   | ||||
		Reference in New Issue
	
	Block a user