1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

remove unpin from body types (#2152)

This commit is contained in:
Rob Ede
2021-04-13 11:16:12 +01:00
committed by GitHub
parent ce50cc9523
commit edd9f14752
19 changed files with 241 additions and 194 deletions

View File

@ -4,11 +4,15 @@ extern crate tls_openssl as openssl;
use std::io;
use actix_http::error::{ErrorBadRequest, PayloadError};
use actix_http::http::header::{self, HeaderName, HeaderValue};
use actix_http::http::{Method, StatusCode, Version};
use actix_http::HttpMessage;
use actix_http::{body, Error, HttpService, Request, Response};
use actix_http::{
body::{Body, SizedStream},
error::{ErrorBadRequest, PayloadError},
http::{
header::{self, HeaderName, HeaderValue},
Method, StatusCode, Version,
},
Error, HttpMessage, HttpService, Request, Response,
};
use actix_http_test::test_server;
use actix_service::{fn_service, ServiceFactoryExt};
use actix_utils::future::{err, ok, ready};
@ -328,7 +332,7 @@ async fn test_h2_body_length() {
.h2(|_| {
let body = once(ok(Bytes::from_static(STR.as_ref())));
ok::<_, ()>(
Response::Ok().body(body::SizedStream::new(STR.len() as u64, body)),
Response::Ok().body(SizedStream::new(STR.len() as u64, body)),
)
})
.openssl(tls_config())
@ -401,7 +405,7 @@ async fn test_h2_response_http_error_handling() {
async fn test_h2_service_error() {
let mut srv = test_server(move || {
HttpService::build()
.h2(|_| err::<Response, Error>(ErrorBadRequest("error")))
.h2(|_| err::<Response<Body>, Error>(ErrorBadRequest("error")))
.openssl(tls_config())
.map_err(|_| ())
})

View File

@ -2,10 +2,15 @@
extern crate tls_rustls as rustls;
use actix_http::error::PayloadError;
use actix_http::http::header::{self, HeaderName, HeaderValue};
use actix_http::http::{Method, StatusCode, Version};
use actix_http::{body, error, Error, HttpService, Request, Response};
use actix_http::{
body::{Body, SizedStream},
error::{self, PayloadError},
http::{
header::{self, HeaderName, HeaderValue},
Method, StatusCode, Version,
},
Error, HttpService, Request, Response,
};
use actix_http_test::test_server;
use actix_service::{fn_factory_with_config, fn_service};
use actix_utils::future::{err, ok};
@ -344,7 +349,7 @@ async fn test_h2_body_length() {
.h2(|_| {
let body = once(ok(Bytes::from_static(STR.as_ref())));
ok::<_, ()>(
Response::Ok().body(body::SizedStream::new(STR.len() as u64, body)),
Response::Ok().body(SizedStream::new(STR.len() as u64, body)),
)
})
.rustls(tls_config())
@ -416,7 +421,7 @@ async fn test_h2_response_http_error_handling() {
async fn test_h2_service_error() {
let mut srv = test_server(move || {
HttpService::build()
.h2(|_| err::<Response, Error>(error::ErrorBadRequest("error")))
.h2(|_| err::<Response<Body>, Error>(error::ErrorBadRequest("error")))
.rustls(tls_config())
})
.await;
@ -433,7 +438,7 @@ async fn test_h2_service_error() {
async fn test_h1_service_error() {
let mut srv = test_server(move || {
HttpService::build()
.h1(|_| err::<Response, Error>(error::ErrorBadRequest("error")))
.h1(|_| err::<Response<Body>, Error>(error::ErrorBadRequest("error")))
.rustls(tls_config())
})
.await;

View File

@ -13,7 +13,10 @@ use regex::Regex;
use actix_http::HttpMessage;
use actix_http::{
body, error, http, http::header, Error, HttpService, KeepAlive, Request, Response,
body::{Body, SizedStream},
error, http,
http::header,
Error, HttpService, KeepAlive, Request, Response,
};
#[actix_rt::test]
@ -539,7 +542,7 @@ async fn test_h1_body_length() {
.h1(|_| {
let body = once(ok(Bytes::from_static(STR.as_ref())));
ok::<_, ()>(
Response::Ok().body(body::SizedStream::new(STR.len() as u64, body)),
Response::Ok().body(SizedStream::new(STR.len() as u64, body)),
)
})
.tcp()
@ -646,7 +649,7 @@ async fn test_h1_response_http_error_handling() {
async fn test_h1_service_error() {
let mut srv = test_server(|| {
HttpService::build()
.h1(|_| err::<Response, _>(error::ErrorBadRequest("error")))
.h1(|_| err::<Response<Body>, _>(error::ErrorBadRequest("error")))
.tcp()
})
.await;