Add failing testcase for HTTP 404 response with no reason text.

This commit is contained in:
Robert G. Jakabosky 2018-09-01 13:24:05 +08:00
parent 66881d7dd1
commit 3784637a56
1 changed files with 23 additions and 0 deletions

View File

@ -932,6 +932,29 @@ fn test_application() {
assert!(response.status().is_success()); assert!(response.status().is_success());
} }
#[test]
fn test_issue_490() {
let mut srv = test::TestServer::with_factory(|| {
App::new()
.prefix("/app")
.resource("", |r| r.f(|_| HttpResponse::Ok()))
.resource("/", |r| r.f(|_| HttpResponse::Ok()))
});
let addr = srv.addr();
let mut buf = [0; 24];
let request = TcpStream::connect(&addr)
.and_then(|sock| {
tokio::io::write_all(sock, "HEAD / HTTP/1.1\r\nHost: localhost\r\n\r\n")
.and_then(|(sock, _)| tokio::io::read_exact(sock, &mut buf))
.and_then(|(_, buf)| Ok(buf))
})
.map_err(|e| panic!("{:?}", e));
let response = srv.execute(request).unwrap();
let rep = String::from_utf8_lossy(&response[..]);
assert!(rep.contains("HTTP/1.1 404 Not Found"));
}
#[test] #[test]
fn test_server_cookies() { fn test_server_cookies() {
use actix_web::http; use actix_web::http;