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:
@ -56,7 +56,7 @@ fn tls_config() -> RustlsServerConfig {
|
||||
async fn test_h1() -> io::Result<()> {
|
||||
let srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.h1(|_| ok::<_, Error>(Response::Ok().finish()))
|
||||
.h1(|_| ok::<_, Error>(Response::ok()))
|
||||
.rustls(tls_config())
|
||||
})
|
||||
.await;
|
||||
@ -70,7 +70,7 @@ async fn test_h1() -> io::Result<()> {
|
||||
async fn test_h2() -> io::Result<()> {
|
||||
let srv = test_server(move || {
|
||||
HttpService::build()
|
||||
.h2(|_| ok::<_, Error>(Response::Ok().finish()))
|
||||
.h2(|_| ok::<_, Error>(Response::ok()))
|
||||
.rustls(tls_config())
|
||||
})
|
||||
.await;
|
||||
@ -87,7 +87,7 @@ async fn test_h1_1() -> io::Result<()> {
|
||||
.h1(|req: Request| {
|
||||
assert!(req.peer_addr().is_some());
|
||||
assert_eq!(req.version(), Version::HTTP_11);
|
||||
ok::<_, Error>(Response::Ok().finish())
|
||||
ok::<_, Error>(Response::ok())
|
||||
})
|
||||
.rustls(tls_config())
|
||||
})
|
||||
@ -105,7 +105,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())
|
||||
})
|
||||
.rustls(tls_config())
|
||||
})
|
||||
@ -123,7 +123,7 @@ async fn test_h2_body1() -> 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))
|
||||
})
|
||||
.rustls(tls_config())
|
||||
})
|
||||
@ -199,7 +199,7 @@ async fn test_h2_headers() {
|
||||
let mut srv = test_server(move || {
|
||||
let data = data.clone();
|
||||
HttpService::build().h2(move |_| {
|
||||
let mut config = Response::Ok();
|
||||
let mut config = Response::build(StatusCode::OK);
|
||||
for idx in 0..90 {
|
||||
config.insert_header((
|
||||
format!("X-TEST-{}", idx).as_str(),
|
||||
@ -257,7 +257,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)))
|
||||
.rustls(tls_config())
|
||||
})
|
||||
.await;
|
||||
@ -274,7 +274,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)))
|
||||
.rustls(tls_config())
|
||||
})
|
||||
.await;
|
||||
@ -300,7 +300,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)))
|
||||
.rustls(tls_config())
|
||||
})
|
||||
.await;
|
||||
@ -325,7 +325,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)))
|
||||
.rustls(tls_config())
|
||||
})
|
||||
.await;
|
||||
@ -349,7 +349,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)),
|
||||
)
|
||||
})
|
||||
.rustls(tls_config())
|
||||
@ -371,7 +371,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),
|
||||
)
|
||||
@ -399,7 +399,7 @@ async fn test_h2_response_http_error_handling() {
|
||||
ok::<_, ()>(fn_service(|_| {
|
||||
let broken_header = Bytes::from_static(b"\0\0\0");
|
||||
ok::<_, ()>(
|
||||
Response::Ok()
|
||||
Response::build(StatusCode::OK)
|
||||
.insert_header((http::header::CONTENT_TYPE, broken_header))
|
||||
.body(STR),
|
||||
)
|
||||
|
Reference in New Issue
Block a user