Implement Response::content_length for wasm32 (#863)
				
					
				
			This commit is contained in:
		| @@ -45,6 +45,22 @@ impl Response { | |||||||
|         self.http.headers_mut() |         self.http.headers_mut() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     /// Get the content-length of this response, if known. | ||||||
|  |     /// | ||||||
|  |     /// Reasons it may not be known: | ||||||
|  |     /// | ||||||
|  |     /// - The server didn't send a `content-length` header. | ||||||
|  |     /// - The response is compressed and automatically decoded (thus changing | ||||||
|  |     //   the actual decoded length). | ||||||
|  |     pub fn content_length(&self) -> Option<u64> { | ||||||
|  |         self.headers() | ||||||
|  |             .get(http::header::CONTENT_LENGTH)? | ||||||
|  |             .to_str() | ||||||
|  |             .ok()? | ||||||
|  |             .parse() | ||||||
|  |             .ok() | ||||||
|  |     } | ||||||
|  |  | ||||||
|     /// Get the final `Url` of this `Response`. |     /// Get the final `Url` of this `Response`. | ||||||
|     #[inline] |     #[inline] | ||||||
|     pub fn url(&self) -> &Url { |     pub fn url(&self) -> &Url { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user