cargo fmt (#151)
This commit is contained in:
@@ -111,25 +111,35 @@ fn cookie_and_redirect(mut stream: TcpStream) -> io::Result<()> {
|
|||||||
stream.write_all(b"Location: /second\r\n")?;
|
stream.write_all(b"Location: /second\r\n")?;
|
||||||
stream.write_all(b"Set-Cookie: first=true\r\n")?;
|
stream.write_all(b"Set-Cookie: first=true\r\n")?;
|
||||||
stream.write_all(b"Content-Length: 0\r\n\r\n")?;
|
stream.write_all(b"Content-Length: 0\r\n\r\n")?;
|
||||||
},
|
}
|
||||||
"/second" => {
|
"/second" => {
|
||||||
if headers.headers().iter().find(|&x| x.contains("first=true")).is_none() {
|
if headers
|
||||||
|
.headers()
|
||||||
|
.iter()
|
||||||
|
.find(|&x| x.contains("first=true"))
|
||||||
|
.is_none()
|
||||||
|
{
|
||||||
panic!("request did not contain cookie 'first'");
|
panic!("request did not contain cookie 'first'");
|
||||||
}
|
}
|
||||||
stream.write_all(b"HTTP/1.1 302 Found\r\n")?;
|
stream.write_all(b"HTTP/1.1 302 Found\r\n")?;
|
||||||
stream.write_all(b"Location: /third\r\n")?;
|
stream.write_all(b"Location: /third\r\n")?;
|
||||||
stream.write_all(b"Set-Cookie: second=true\r\n")?;
|
stream.write_all(b"Set-Cookie: second=true\r\n")?;
|
||||||
stream.write_all(b"Content-Length: 0\r\n\r\n")?;
|
stream.write_all(b"Content-Length: 0\r\n\r\n")?;
|
||||||
},
|
}
|
||||||
"/third" => {
|
"/third" => {
|
||||||
if headers.headers().iter().find(|&x| x.contains("second=true")).is_none() {
|
if headers
|
||||||
|
.headers()
|
||||||
|
.iter()
|
||||||
|
.find(|&x| x.contains("second=true"))
|
||||||
|
.is_none()
|
||||||
|
{
|
||||||
panic!("request did not contain cookie 'second'");
|
panic!("request did not contain cookie 'second'");
|
||||||
}
|
}
|
||||||
stream.write_all(b"HTTP/1.1 200 OK\r\n")?;
|
stream.write_all(b"HTTP/1.1 200 OK\r\n")?;
|
||||||
stream.write_all(b"Set-Cookie: third=true\r\n")?;
|
stream.write_all(b"Set-Cookie: third=true\r\n")?;
|
||||||
stream.write_all(b"Content-Length: 0\r\n\r\n")?;
|
stream.write_all(b"Content-Length: 0\r\n\r\n")?;
|
||||||
},
|
}
|
||||||
_ => {},
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -363,7 +363,11 @@ fn send_prelude(unit: &Unit, stream: &mut Stream, redir: bool) -> IoResult<()> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !header::has_header(&unit.headers, "user-agent") {
|
if !header::has_header(&unit.headers, "user-agent") {
|
||||||
write!(prelude, "User-Agent: ureq/{}\r\n", env!("CARGO_PKG_VERSION"))?;
|
write!(
|
||||||
|
prelude,
|
||||||
|
"User-Agent: ureq/{}\r\n",
|
||||||
|
env!("CARGO_PKG_VERSION")
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
if !header::has_header(&unit.headers, "accept") {
|
if !header::has_header(&unit.headers, "accept") {
|
||||||
write!(prelude, "Accept: */*\r\n")?;
|
write!(prelude, "Accept: */*\r\n")?;
|
||||||
|
|||||||
Reference in New Issue
Block a user