add Response::remote_addr() method
The new `remote_addr` method returns an `Option<SocketAddr>`, which is `Some` if the underlying transport uses socket addresses. Closes #373
This commit is contained in:
		| @@ -1,6 +1,7 @@ | ||||
| use std::mem; | ||||
| use std::fmt; | ||||
| use std::io::{self, Read}; | ||||
| use std::net::SocketAddr; | ||||
| use std::time::Duration; | ||||
| use std::borrow::Cow; | ||||
|  | ||||
| @@ -61,6 +62,22 @@ impl Response { | ||||
|         self.inner.url() | ||||
|     } | ||||
|  | ||||
|     /// Get the remote address used to get this `Response`. | ||||
|     /// | ||||
|     /// # Example | ||||
|     /// | ||||
|     /// ```rust | ||||
|     /// # fn run() -> Result<(), Box<::std::error::Error>> { | ||||
|     /// let resp = reqwest::get("http://httpbin.org/redirect/1")?; | ||||
|     /// println!("httpbin.org address: {:?}", resp.remote_addr()); | ||||
|     /// # Ok(()) | ||||
|     /// # } | ||||
|     /// ``` | ||||
|     pub fn remote_addr(&self) -> Option<SocketAddr> { | ||||
|         self.inner.remote_addr() | ||||
|  | ||||
|     } | ||||
|  | ||||
|     /// Get the `StatusCode` of this `Response`. | ||||
|     /// | ||||
|     /// # Examples | ||||
|   | ||||
		Reference in New Issue
	
	Block a user