Request: rename path field to URL. (#104)

* Request: rename path field to URL.

This more accurately reflects its use.
This commit is contained in:
Jacob Hoffman-Andrews
2020-07-01 00:53:10 -07:00
committed by GitHub
parent e4ad3a5e5f
commit ea7ed88399

View File

@@ -39,7 +39,7 @@ pub struct Request {
// via agent // via agent
pub(crate) method: String, pub(crate) method: String,
path: String, url: String,
// from request itself // from request itself
pub(crate) headers: Vec<Header>, pub(crate) headers: Vec<Header>,
@@ -72,11 +72,11 @@ impl ::std::fmt::Debug for Request {
} }
impl Request { impl Request {
pub(crate) fn new(agent: &Agent, method: String, path: String) -> Request { pub(crate) fn new(agent: &Agent, method: String, url: String) -> Request {
Request { Request {
agent: Arc::clone(&agent.state), agent: Arc::clone(&agent.state),
method, method,
path, url,
headers: agent.headers.clone(), headers: agent.headers.clone(),
redirects: 5, redirects: 5,
..Default::default() ..Default::default()
@@ -512,7 +512,7 @@ impl Request {
/// assert_eq!(req.get_url(), "https://cool.server/innit"); /// assert_eq!(req.get_url(), "https://cool.server/innit");
/// ``` /// ```
pub fn get_url(&self) -> &str { pub fn get_url(&self) -> &str {
&self.path &self.url
} }
/// Normalizes and returns the host that will be used for this request. /// Normalizes and returns the host that will be used for this request.
@@ -558,7 +558,7 @@ impl Request {
.map(|u| unit::combine_query(&u, &self.query, true)) .map(|u| unit::combine_query(&u, &self.query, true))
} }
/// The normalized path of this request. /// The normalized url of this request.
/// ///
/// Example: /// Example:
/// ``` /// ```
@@ -572,7 +572,7 @@ impl Request {
fn to_url(&self) -> Result<Url, Error> { fn to_url(&self) -> Result<Url, Error> {
URL_BASE URL_BASE
.join(&self.path) .join(&self.url)
.map_err(|e| Error::BadUrl(format!("{}", e))) .map_err(|e| Error::BadUrl(format!("{}", e)))
} }