reuse agent

This commit is contained in:
Martin Algesten
2018-06-11 23:00:45 +02:00
parent 8bc8559c22
commit 2cb3d4f066
2 changed files with 29 additions and 0 deletions

28
src/test/agent.rs Normal file
View File

@@ -0,0 +1,28 @@
use test;
use super::super::*;
#[test]
fn agent_reuse_headers() {
let agent = agent()
.set("Authorization", "Foo 12345")
.build();
test::set_handler("/agent_reuse_headers", |req, _url| {
assert!(req.has("Authorization"));
assert_eq!(req.get("Authorization").unwrap(), "Foo 12345");
test::make_stream(200, "OK", vec!["X-Call: 1"], vec![])
});
let resp = agent.get("test://host/agent_reuse_headers").call();
assert_eq!(resp.get("X-Call").unwrap(), "1");
test::set_handler("/agent_reuse_headers", |req, _url| {
assert!(req.has("Authorization"));
assert_eq!(req.get("Authorization").unwrap(), "Foo 12345");
test::make_stream(200, "OK", vec!["X-Call: 2"], vec![])
});
let resp = agent.get("test://host/agent_reuse_headers").call();
assert_eq!(resp.get("X-Call").unwrap(), "2");
}