Add Response::text() to async Client
This commit is contained in:
@@ -29,6 +29,42 @@ fn gzip_single_byte_chunks() {
|
||||
gzip_case(10, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn response_text() {
|
||||
let _ = env_logger::try_init();
|
||||
|
||||
let server = server! {
|
||||
request: b"\
|
||||
GET /text HTTP/1.1\r\n\
|
||||
user-agent: $USERAGENT\r\n\
|
||||
accept: */*\r\n\
|
||||
accept-encoding: gzip\r\n\
|
||||
host: $HOST\r\n\
|
||||
\r\n\
|
||||
",
|
||||
response: b"\
|
||||
HTTP/1.1 200 OK\r\n\
|
||||
Content-Length: 5\r\n\
|
||||
\r\n\
|
||||
Hello\
|
||||
"
|
||||
};
|
||||
|
||||
let mut rt = Runtime::new().expect("new rt");
|
||||
|
||||
let client = Client::new();
|
||||
|
||||
let res_future = client.get(&format!("http://{}/text", server.addr()))
|
||||
.send()
|
||||
.and_then(|mut res| res.text())
|
||||
.and_then(|text| {
|
||||
assert_eq!("Hello", text);
|
||||
Ok(())
|
||||
});
|
||||
|
||||
rt.block_on(res_future).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multipart() {
|
||||
let _ = env_logger::try_init();
|
||||
|
||||
Reference in New Issue
Block a user