From b53de7a7edfb726c57262e6ff5f7b98ba98f7f53 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Thu, 2 Jul 2020 23:01:51 -0700 Subject: [PATCH 1/2] Remove default URL_BASE of localhost. --- src/request.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/request.rs b/src/request.rs index 715fb36..504115d 100644 --- a/src/request.rs +++ b/src/request.rs @@ -2,7 +2,6 @@ use std::io::Read; use std::sync::{Arc, Mutex}; use std::time; -use lazy_static::lazy_static; use qstring::QString; use url::{form_urlencoded, Url}; @@ -20,10 +19,6 @@ use crate::Response; #[cfg(feature = "json")] use super::SerdeValue; -lazy_static! { - static ref URL_BASE: Url = Url::parse("http://localhost/").expect("Failed to parse URL_BASE"); -} - /// Request instances are builders that creates a request. /// /// ``` @@ -571,9 +566,7 @@ impl Request { } fn to_url(&self) -> Result { - URL_BASE - .join(&self.url) - .map_err(|e| Error::BadUrl(format!("{}", e))) + Url::parse(&self.url).map_err(|e| Error::BadUrl(format!("{}", e))) } /// Set the proxy server to use for the connection. From 7fce93d1c8377d8023b72a8ce0fe8a383b90c7c2 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Thu, 2 Jul 2020 23:07:49 -0700 Subject: [PATCH 2/2] Fix tests. --- src/request.rs | 2 +- src/test/simple.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/request.rs b/src/request.rs index 504115d..bf444d1 100644 --- a/src/request.rs +++ b/src/request.rs @@ -518,7 +518,7 @@ impl Request { /// .build(); /// assert_eq!(req1.get_host().unwrap(), "cool.server"); /// - /// let req2 = ureq::post("/some/path") + /// let req2 = ureq::post("http://localhost/some/path") /// .build(); /// assert_eq!(req2.get_host().unwrap(), "localhost"); /// ``` diff --git a/src/test/simple.rs b/src/test/simple.rs index 0c4a508..fd7cc3c 100644 --- a/src/test/simple.rs +++ b/src/test/simple.rs @@ -122,7 +122,7 @@ fn escape_path() { #[test] fn request_debug() { - let req = get("/my/page") + let req = get("http://localhost/my/page") .set("Authorization", "abcdef") .set("Content-Length", "1234") .set("Content-Type", "application/json") @@ -136,7 +136,7 @@ fn request_debug() { Content-Length: 1234, Content-Type: application/json])" ); - let req = get("/my/page?q=z") + let req = get("http://localhost/my/page?q=z") .query("foo", "bar baz") .set("Authorization", "abcdef") .build();