mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-26 15:07:42 +02:00
remove http-codes builders from actix-http (#2159)
This commit is contained in:
@ -71,7 +71,7 @@ fn tls_config() -> SslAcceptor {
|
||||
async fn test_h2() -> io::Result<()> {
|
||||
let srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.h2(|_| ok::<_, Error>(Response::Ok().finish()))
|
||||
.h2(|_| ok::<_, Error>(Response::ok()))
|
||||
.openssl(tls_config())
|
||||
.map_err(|_| ())
|
||||
})
|
||||
@ -89,7 +89,7 @@ async fn test_h2_1() -> io::Result<()> {
|
||||
.finish(|req: Request| {
|
||||
assert!(req.peer_addr().is_some());
|
||||
assert_eq!(req.version(), Version::HTTP_2);
|
||||
ok::<_, Error>(Response::Ok().finish())
|
||||
ok::<_, Error>(Response::ok())
|
||||
})
|
||||
.openssl(tls_config())
|
||||
.map_err(|_| ())
|
||||
@ -108,7 +108,7 @@ async fn test_h2_body() -> io::Result<()> {
|
||||
HttpService::build()
|
||||
.h2(|mut req: Request<_>| async move {
|
||||
let body = load_body(req.take_payload()).await?;
|
||||
Ok::<_, Error>(Response::Ok().body(body))
|
||||
Ok::<_, Error>(Response::ok().set_body(body))
|
||||
})
|
||||
.openssl(tls_config())
|
||||
.map_err(|_| ())
|
||||
@ -186,7 +186,7 @@ async fn test_h2_headers() {
|
||||
let mut srv = test_server(move || {
|
||||
let data = data.clone();
|
||||
HttpService::build().h2(move |_| {
|
||||
let mut builder = Response::Ok();
|
||||
let mut builder = Response::build(StatusCode::OK);
|
||||
for idx in 0..90 {
|
||||
builder.insert_header(
|
||||
(format!("X-TEST-{}", idx).as_str(),
|
||||
@ -245,7 +245,7 @@ const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||
async fn test_h2_body2() {
|
||||
let mut srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.h2(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.h2(|_| ok::<_, ()>(Response::ok().set_body(STR)))
|
||||
.openssl(tls_config())
|
||||
.map_err(|_| ())
|
||||
})
|
||||
@ -263,7 +263,7 @@ async fn test_h2_body2() {
|
||||
async fn test_h2_head_empty() {
|
||||
let mut srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.finish(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.finish(|_| ok::<_, ()>(Response::ok().set_body(STR)))
|
||||
.openssl(tls_config())
|
||||
.map_err(|_| ())
|
||||
})
|
||||
@ -287,7 +287,7 @@ async fn test_h2_head_empty() {
|
||||
async fn test_h2_head_binary() {
|
||||
let mut srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.h2(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.h2(|_| ok::<_, ()>(Response::ok().set_body(STR)))
|
||||
.openssl(tls_config())
|
||||
.map_err(|_| ())
|
||||
})
|
||||
@ -310,7 +310,7 @@ async fn test_h2_head_binary() {
|
||||
async fn test_h2_head_binary2() {
|
||||
let srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.h2(|_| ok::<_, ()>(Response::Ok().body(STR)))
|
||||
.h2(|_| ok::<_, ()>(Response::ok().set_body(STR)))
|
||||
.openssl(tls_config())
|
||||
.map_err(|_| ())
|
||||
})
|
||||
@ -332,7 +332,7 @@ async fn test_h2_body_length() {
|
||||
.h2(|_| {
|
||||
let body = once(ok(Bytes::from_static(STR.as_ref())));
|
||||
ok::<_, ()>(
|
||||
Response::Ok().body(SizedStream::new(STR.len() as u64, body)),
|
||||
Response::ok().set_body(SizedStream::new(STR.len() as u64, body)),
|
||||
)
|
||||
})
|
||||
.openssl(tls_config())
|
||||
@ -355,7 +355,7 @@ async fn test_h2_body_chunked_explicit() {
|
||||
.h2(|_| {
|
||||
let body = once(ok::<_, Error>(Bytes::from_static(STR.as_ref())));
|
||||
ok::<_, ()>(
|
||||
Response::Ok()
|
||||
Response::build(StatusCode::OK)
|
||||
.insert_header((header::TRANSFER_ENCODING, "chunked"))
|
||||
.streaming(body),
|
||||
)
|
||||
@ -383,7 +383,7 @@ async fn test_h2_response_http_error_handling() {
|
||||
.h2(fn_service(|_| {
|
||||
let broken_header = Bytes::from_static(b"\0\0\0");
|
||||
ok::<_, ()>(
|
||||
Response::Ok()
|
||||
Response::build(StatusCode::OK)
|
||||
.insert_header((header::CONTENT_TYPE, broken_header))
|
||||
.body(STR),
|
||||
)
|
||||
@ -428,7 +428,7 @@ async fn test_h2_on_connect() {
|
||||
})
|
||||
.h2(|req: Request| {
|
||||
assert!(req.extensions().contains::<isize>());
|
||||
ok::<_, ()>(Response::Ok().finish())
|
||||
ok::<_, ()>(Response::ok())
|
||||
})
|
||||
.openssl(tls_config())
|
||||
.map_err(|_| ())
|
||||
|
Reference in New Issue
Block a user