1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-10-12 05:02:27 +00:00
actix-web/tests/test_h1v2.rs

47 lines
1.3 KiB
Rust
Raw Normal View History

2018-10-04 23:22:00 +00:00
extern crate actix;
2018-10-05 00:00:27 +00:00
extern crate actix_http;
2018-10-04 23:22:00 +00:00
extern crate actix_net;
extern crate actix_web;
extern crate futures;
use std::thread;
use actix::System;
use actix_net::server::Server;
2018-10-05 00:00:27 +00:00
use actix_web::{client, test};
2018-10-04 23:22:00 +00:00
use futures::future;
2018-10-05 18:04:59 +00:00
use actix_http::{h1, Error, KeepAlive, Response, ServiceConfig};
2018-10-04 23:22:00 +00:00
#[test]
fn test_h1_v2() {
let addr = test::TestServer::unused_addr();
thread::spawn(move || {
Server::new()
.bind("test", addr, move || {
2018-10-05 00:00:27 +00:00
let settings = ServiceConfig::build()
2018-10-04 23:22:00 +00:00
.keep_alive(KeepAlive::Disabled)
.client_timeout(1000)
2018-10-05 12:59:02 +00:00
.client_disconnect(1000)
2018-10-04 23:22:00 +00:00
.server_hostname("localhost")
.server_address(addr)
.finish();
2018-10-05 03:02:10 +00:00
h1::H1Service::new(settings, |req| {
println!("REQ: {:?}", req);
2018-10-05 18:04:59 +00:00
future::ok::<_, Error>(Response::Ok().finish())
2018-10-05 03:02:10 +00:00
})
2018-10-04 23:22:00 +00:00
}).unwrap()
.run();
});
let mut sys = System::new("test");
{
let req = client::ClientRequest::get(format!("http://{}/", addr).as_str())
.finish()
.unwrap();
let response = sys.block_on(req.send()).unwrap();
assert!(response.status().is_success());
}
}