From b9e3d3e76c695ef0e94db68ede0463ba2b156dd4 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sun, 6 Dec 2020 14:55:55 -0800 Subject: [PATCH] Fix test --- src/agent.rs | 2 ++ src/testserver.rs | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/agent.rs b/src/agent.rs index 691cb93..5c018cc 100644 --- a/src/agent.rs +++ b/src/agent.rs @@ -417,6 +417,8 @@ impl AgentBuilder { /// let result = ureq::builder() /// .redirects(1) /// .build() + /// # ; + /// # let result = ureq::agent() /// .get("http://httpbin.org/status/301") /// .call()?; /// assert_ne!(result.status(), 301); diff --git a/src/testserver.rs b/src/testserver.rs index 8d7ea63..3cdef51 100644 --- a/src/testserver.rs +++ b/src/testserver.rs @@ -17,6 +17,8 @@ pub(crate) fn test_agent() -> Agent { let headers = read_request(&stream); if headers.0.is_empty() { // no headers probably means it's the initial request to check test server is up. + } else if headers.path() == "/status/200" { + stream.write_all(b"HTTP/1.1 200 OK\r\n\r\n")?; } else if headers.path() == "/status/500" { stream.write_all(b"HTTP/1.1 500 Server Internal Error\r\n\r\n")?; } else if headers.path() == "/bytes/100" { @@ -30,11 +32,11 @@ pub(crate) fn test_agent() -> Agent { stream.write_all(br#"{"hello": "world"}"#)?; } else if headers.path() == "/status/301" { stream.write_all(b"HTTP/1.1 301 Found\r\n")?; - stream.write_all(b"Location: /redirect/3\r\n")?; + stream.write_all(b"Location: /status/200\r\n")?; stream.write_all(b"\r\n")?; } else if headers.path() == "/status/307" { stream.write_all(b"HTTP/1.1 307 Found\r\n")?; - stream.write_all(b"Location: /redirect/3\r\n")?; + stream.write_all(b"Location: /status/200\r\n")?; stream.write_all(b"\r\n")?; } else { stream.write_all(b"HTTP/1.1 200 OK\r\n")?;