1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-01-19 06:04:40 +01:00

Merge pull request #1529 from JohnTitor/next-web

web: Bump up to 3.0.0-alpha.3
This commit is contained in:
Yuki Okushi 2020-05-21 19:32:24 +09:00 committed by GitHub
commit b9e268e95f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 54 additions and 49 deletions

View File

@ -1,6 +1,6 @@
# Changes # Changes
## [Unreleased] ## [3.0.0-alpha.3] - 2020-05-21
### Added ### Added

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-web" name = "actix-web"
version = "3.0.0-alpha.2" version = "3.0.0-alpha.3"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust." description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
readme = "README.md" readme = "README.md"

View File

@ -18,7 +18,7 @@ name = "actix_files"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = { version = "3.0.0-alpha.2", default-features = false } actix-web = { version = "3.0.0-alpha.3", default-features = false }
actix-http = "2.0.0-alpha.4" actix-http = "2.0.0-alpha.4"
actix-service = "1.0.1" actix-service = "1.0.1"
bitflags = "1" bitflags = "1"
@ -34,4 +34,4 @@ v_htmlescape = "0.4"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0" actix-rt = "1.0.0"
actix-web = { version = "3.0.0-alpha.2", features = ["openssl"] } actix-web = { version = "3.0.0-alpha.3", features = ["openssl"] }

View File

@ -16,7 +16,7 @@ name = "actix_multipart"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = { version = "3.0.0-alpha.2", default-features = false } actix-web = { version = "3.0.0-alpha.3", default-features = false }
actix-service = "1.0.1" actix-service = "1.0.1"
actix-utils = "1.0.3" actix-utils = "1.0.3"
bytes = "0.5.3" bytes = "0.5.3"

View File

@ -17,7 +17,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix = "0.10.0-alpha.2" actix = "0.10.0-alpha.2"
actix-web = "3.0.0-alpha.2" actix-web = "3.0.0-alpha.3"
actix-http = "2.0.0-alpha.4" actix-http = "2.0.0-alpha.4"
actix-codec = "0.2.0" actix-codec = "0.2.0"
bytes = "0.5.2" bytes = "0.5.2"

View File

@ -18,5 +18,5 @@ proc-macro2 = "^1"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0" actix-rt = "1.0.0"
actix-web = "3.0.0-alpha.2" actix-web = "3.0.0-alpha.3"
futures-util = { version = "0.3.5", default-features = false } futures-util = { version = "0.3.5", default-features = false }

View File

@ -55,7 +55,7 @@ rust-tls = { version = "0.17.0", package = "rustls", optional = true, features =
[dev-dependencies] [dev-dependencies]
actix-connect = { version = "2.0.0-alpha.2", features = ["openssl"] } actix-connect = { version = "2.0.0-alpha.2", features = ["openssl"] }
actix-web = { version = "3.0.0-alpha.2", features = ["openssl"] } actix-web = { version = "3.0.0-alpha.3", features = ["openssl"] }
actix-http = { version = "2.0.0-alpha.4", features = ["openssl"] } actix-http = { version = "2.0.0-alpha.4", features = ["openssl"] }
actix-http-test = { version = "1.0.0", features = ["openssl"] } actix-http-test = { version = "1.0.0", features = ["openssl"] }
actix-utils = "1.0.3" actix-utils = "1.0.3"

View File

@ -474,13 +474,15 @@ where
mod tests { mod tests {
use actix_service::Service; use actix_service::Service;
use bytes::Bytes; use bytes::Bytes;
use futures_util::future::{ok, err}; use futures_util::future::{err, ok};
use super::*; use super::*;
use crate::http::{header, HeaderValue, Method, StatusCode}; use crate::http::{header, HeaderValue, Method, StatusCode};
use crate::middleware::DefaultHeaders; use crate::middleware::DefaultHeaders;
use crate::service::ServiceRequest; use crate::service::ServiceRequest;
use crate::test::{call_service, init_service, try_init_service, read_body, TestRequest}; use crate::test::{
call_service, init_service, read_body, try_init_service, TestRequest,
};
use crate::{web, HttpRequest, HttpResponse}; use crate::{web, HttpRequest, HttpResponse};
#[actix_rt::test] #[actix_rt::test]

View File

@ -273,13 +273,15 @@ impl<B> PinnedDrop for StreamLog<B> {
} }
} }
impl<B: MessageBody> MessageBody for StreamLog<B> { impl<B: MessageBody> MessageBody for StreamLog<B> {
fn size(&self) -> BodySize { fn size(&self) -> BodySize {
self.body.size() self.body.size()
} }
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Result<Bytes, Error>>> { fn poll_next(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Bytes, Error>>> {
let this = self.project(); let this = self.project();
match this.body.poll_next(cx) { match this.body.poll_next(cx) {
Poll::Ready(Some(Ok(chunk))) => { Poll::Ready(Some(Ok(chunk))) => {
@ -324,11 +326,13 @@ impl Format {
if let Some(key) = cap.get(2) { if let Some(key) = cap.get(2) {
results.push(match cap.get(3).unwrap().as_str() { results.push(match cap.get(3).unwrap().as_str() {
"a" => if key.as_str() == "r" { "a" => {
if key.as_str() == "r" {
FormatText::RealIPRemoteAddr FormatText::RealIPRemoteAddr
} else { } else {
unreachable!() unreachable!()
}, }
}
"i" => FormatText::RequestHeader( "i" => FormatText::RequestHeader(
HeaderName::try_from(key.as_str()).unwrap(), HeaderName::try_from(key.as_str()).unwrap(),
), ),
@ -481,7 +485,8 @@ impl FormatText {
*self = s; *self = s;
} }
FormatText::RealIPRemoteAddr => { FormatText::RealIPRemoteAddr => {
let s = if let Some(remote) = req.connection_info().realip_remote_addr() { let s = if let Some(remote) = req.connection_info().realip_remote_addr()
{
FormatText::Str(remote.to_string()) FormatText::Str(remote.to_string())
} else { } else {
FormatText::Str("-".to_string()) FormatText::Str("-".to_string())
@ -630,7 +635,9 @@ mod tests {
let req = TestRequest::with_header( let req = TestRequest::with_header(
header::FORWARDED, header::FORWARDED,
header::HeaderValue::from_static("for=192.0.2.60;proto=http;by=203.0.113.43"), header::HeaderValue::from_static(
"for=192.0.2.60;proto=http;by=203.0.113.43",
),
) )
.to_srv_request(); .to_srv_request();

View File

@ -362,31 +362,23 @@ mod tests {
.service( .service(
web::resource("/test") web::resource("/test")
.route(web::get().to(|| HttpResponse::Ok())) .route(web::get().to(|| HttpResponse::Ok()))
.route(web::put().to(|| { .route(web::put().to(|| async {
async {
Err::<HttpResponse, _>(error::ErrorBadRequest("err")) Err::<HttpResponse, _>(error::ErrorBadRequest("err"))
}
})) }))
.route(web::post().to(|| { .route(web::post().to(|| async {
async {
delay_for(Duration::from_millis(100)).await; delay_for(Duration::from_millis(100)).await;
HttpResponse::Created() HttpResponse::Created()
}
})) }))
.route(web::delete().to(|| { .route(web::delete().to(|| async {
async {
delay_for(Duration::from_millis(100)).await; delay_for(Duration::from_millis(100)).await;
Err::<HttpResponse, _>(error::ErrorBadRequest("err")) Err::<HttpResponse, _>(error::ErrorBadRequest("err"))
}
})), })),
) )
.service(web::resource("/json").route(web::get().to(|| { .service(web::resource("/json").route(web::get().to(|| async {
async {
delay_for(Duration::from_millis(25)).await; delay_for(Duration::from_millis(25)).await;
web::Json(MyObject { web::Json(MyObject {
name: "test".to_string(), name: "test".to_string(),
}) })
}
}))), }))),
) )
.await; .await;

View File

@ -89,7 +89,9 @@ where
>, >,
S::InitError: std::fmt::Debug, S::InitError: std::fmt::Debug,
{ {
try_init_service(app).await.expect("service initilization failed") try_init_service(app)
.await
.expect("service initilization failed")
} }
/// Fallible version of init_service that allows testing data factory errors. /// Fallible version of init_service that allows testing data factory errors.
@ -913,7 +915,8 @@ impl TestServerConfig {
/// Get first available unused address /// Get first available unused address
pub fn unused_addr() -> net::SocketAddr { pub fn unused_addr() -> net::SocketAddr {
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap(); let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap(); let socket =
Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
socket.bind(&addr.into()).unwrap(); socket.bind(&addr.into()).unwrap();
socket.set_reuse_address(true).unwrap(); socket.set_reuse_address(true).unwrap();
let tcp = socket.into_tcp_listener(); let tcp = socket.into_tcp_listener();

View File

@ -55,5 +55,5 @@ time = { version = "0.2.7", default-features = false, features = ["std"] }
open-ssl = { version = "0.10", package = "openssl", optional = true } open-ssl = { version = "0.10", package = "openssl", optional = true }
[dev-dependencies] [dev-dependencies]
actix-web = "3.0.0-alpha.2" actix-web = "3.0.0-alpha.3"
actix-http = "2.0.0-alpha.4" actix-http = "2.0.0-alpha.4"

View File

@ -349,9 +349,10 @@ async fn test_body_br_streaming() {
#[actix_rt::test] #[actix_rt::test]
async fn test_head_binary() { async fn test_head_binary() {
let srv = test::start_with(test::config().h1(), || { let srv = test::start_with(test::config().h1(), || {
App::new().service(web::resource("/").route( App::new().service(
web::head().to(move || HttpResponse::Ok().body(STR)), web::resource("/")
)) .route(web::head().to(move || HttpResponse::Ok().body(STR))),
)
}); });
let mut response = srv.head("/").send().await.unwrap(); let mut response = srv.head("/").send().await.unwrap();