1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-12-02 19:32:24 +01:00

use released versions of actix-net

This commit is contained in:
Nikolay Kim 2019-12-02 23:33:39 +06:00
parent 068f047dd5
commit 14075ebf7f
19 changed files with 128 additions and 126 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-web" name = "actix-web"
version = "2.0.0-alpha.1" version = "2.0.0-alpha.2"
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"
@ -69,19 +69,18 @@ openssl = ["open-ssl", "actix-tls/openssl", "awc/openssl"]
# rustls = ["rust-tls", "actix-server/rustls", "awc/rustls"] # rustls = ["rust-tls", "actix-server/rustls", "awc/rustls"]
[dependencies] [dependencies]
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"
actix-router = "0.1.5" actix-router = "0.1.5"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-web-codegen = "0.2.0-alpha.1" actix-web-codegen = "0.2.0-alpha.2"
actix-http = "0.3.0-alpha.1" actix-http = "0.3.0-alpha.2"
actix-server = "0.8.0-alpha.2" actix-server = "1.0.0-alpha.2"
actix-testing = "0.3.0-alpha.1" actix-testing = "1.0.0-alpha.2"
actix-threadpool = "0.2.0-alpha.1" actix-threadpool = "0.3.0"
#actix-tls = "0.1.0-alpha.1" actix-tls = { version = "1.0.0-alpha.1", optional = true }
actix-tls = { git = "https://github.com/actix/actix-net.git", optional = true } awc = { version = "0.3.0-alpha.2", optional = true }
awc = { version = "0.3.0-alpha.1", optional = true }
bytes = "0.4" bytes = "0.4"
derive_more = "0.99.2" derive_more = "0.99.2"
@ -92,7 +91,7 @@ log = "0.4"
mime = "0.3" mime = "0.3"
net2 = "0.2.33" net2 = "0.2.33"
parking_lot = "0.9" parking_lot = "0.9"
pin-project = "0.4.5" pin-project = "0.4.6"
regex = "1.0" regex = "1.0"
serde = { version = "1.0", features=["derive"] } serde = { version = "1.0", features=["derive"] }
serde_json = "1.0" serde_json = "1.0"
@ -106,8 +105,8 @@ open-ssl = { version="0.10", package="openssl", optional = true }
[dev-dependencies] [dev-dependencies]
# actix = "0.8.3" # actix = "0.8.3"
actix-connect = "0.3.0-alpha.1" actix-connect = "1.0.0-alpha.2"
actix-http-test = "0.3.0-alpha.1" actix-http-test = "0.3.0-alpha.2"
rand = "0.7" rand = "0.7"
env_logger = "0.6" env_logger = "0.6"
serde_derive = "1.0" serde_derive = "1.0"
@ -131,12 +130,12 @@ actix-files = { path = "actix-files" }
actix-multipart = { path = "actix-multipart" } actix-multipart = { path = "actix-multipart" }
awc = { path = "awc" } awc = { path = "awc" }
actix-codec = { git = "https://github.com/actix/actix-net.git" } # actix-codec = { git = "https://github.com/actix/actix-net.git" }
actix-connect = { git = "https://github.com/actix/actix-net.git" } # actix-connect = { git = "https://github.com/actix/actix-net.git" }
actix-rt = { git = "https://github.com/actix/actix-net.git" } # actix-rt = { git = "https://github.com/actix/actix-net.git" }
actix-macros = { git = "https://github.com/actix/actix-net.git" } # actix-macros = { git = "https://github.com/actix/actix-net.git" }
actix-server = { git = "https://github.com/actix/actix-net.git" } # actix-server = { git = "https://github.com/actix/actix-net.git" }
actix-service = { git = "https://github.com/actix/actix-net.git" } # actix-service = { git = "https://github.com/actix/actix-net.git" }
actix-testing = { git = "https://github.com/actix/actix-net.git" } # actix-testing = { git = "https://github.com/actix/actix-net.git" }
actix-tls = { git = "https://github.com/actix/actix-net.git" } # actix-tls = { git = "https://github.com/actix/actix-net.git" }
actix-utils = { git = "https://github.com/actix/actix-net.git" } # actix-utils = { git = "https://github.com/actix/actix-net.git" }

View File

@ -18,9 +18,9 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = "2.0.0-alpha.1" actix-web = "2.0.0-alpha.1"
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
derive_more = "0.99.2" derive_more = "0.99.2"
futures = "0.3.1" futures = "0.3.1"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"

View File

@ -20,7 +20,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = { version = "2.0.0-alpha.1", default-features = false } actix-web = { version = "2.0.0-alpha.1", default-features = false }
actix-http = "0.3.0-alpha.1" actix-http = "0.3.0-alpha.1"
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
bitflags = "1" bitflags = "1"
bytes = "0.4" bytes = "0.4"
futures = "0.3.1" futures = "0.3.1"
@ -32,5 +32,5 @@ percent-encoding = "2.1"
v_htmlescape = "0.4" v_htmlescape = "0.4"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-web = { version = "2.0.0-alpha.1", features=["openssl"] } actix-web = { version = "2.0.0-alpha.1", features=["openssl"] }

View File

@ -18,7 +18,7 @@ use actix_web::dev::{
AppService, HttpServiceFactory, Payload, ResourceDef, ServiceRequest, AppService, HttpServiceFactory, Payload, ResourceDef, ServiceRequest,
ServiceResponse, ServiceResponse,
}; };
use actix_web::error::{Canceled, Error, ErrorInternalServerError}; use actix_web::error::{BlockingError, Error, ErrorInternalServerError};
use actix_web::guard::Guard; use actix_web::guard::Guard;
use actix_web::http::header::{self, DispositionType}; use actix_web::http::header::{self, DispositionType};
use actix_web::http::Method; use actix_web::http::Method;
@ -50,6 +50,12 @@ pub fn file_extension_to_mime(ext: &str) -> mime::Mime {
from_ext(ext).first_or_octet_stream() from_ext(ext).first_or_octet_stream()
} }
fn handle_error(err: BlockingError<io::Error>) -> Error {
match err {
BlockingError::Error(err) => err.into(),
BlockingError::Canceled => ErrorInternalServerError("Unexpected error"),
}
}
#[doc(hidden)] #[doc(hidden)]
/// A helper created from a `std::fs::File` which reads the file /// A helper created from a `std::fs::File` which reads the file
/// chunk-by-chunk on a `ThreadPool`. /// chunk-by-chunk on a `ThreadPool`.
@ -57,9 +63,8 @@ pub struct ChunkedReadFile {
size: u64, size: u64,
offset: u64, offset: u64,
file: Option<File>, file: Option<File>,
fut: Option< fut:
LocalBoxFuture<'static, Result<Result<(File, Bytes), io::Error>, Canceled>>, Option<LocalBoxFuture<'static, Result<(File, Bytes), BlockingError<io::Error>>>>,
>,
counter: u64, counter: u64,
} }
@ -72,18 +77,14 @@ impl Stream for ChunkedReadFile {
) -> Poll<Option<Self::Item>> { ) -> Poll<Option<Self::Item>> {
if let Some(ref mut fut) = self.fut { if let Some(ref mut fut) = self.fut {
return match Pin::new(fut).poll(cx) { return match Pin::new(fut).poll(cx) {
Poll::Ready(Err(_)) => Poll::Ready(Some(Err(ErrorInternalServerError( Poll::Ready(Ok((file, bytes))) => {
"Unexpected error",
)
.into()))),
Poll::Ready(Ok(Ok((file, bytes)))) => {
self.fut.take(); self.fut.take();
self.file = Some(file); self.file = Some(file);
self.offset += bytes.len() as u64; self.offset += bytes.len() as u64;
self.counter += bytes.len() as u64; self.counter += bytes.len() as u64;
Poll::Ready(Some(Ok(bytes))) Poll::Ready(Some(Ok(bytes)))
} }
Poll::Ready(Ok(Err(e))) => Poll::Ready(Some(Err(e.into()))), Poll::Ready(Err(e)) => Poll::Ready(Some(Err(handle_error(e)))),
Poll::Pending => Poll::Pending, Poll::Pending => Poll::Pending,
}; };
} }

View File

@ -20,11 +20,11 @@ name = "actix_framed"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-router = "0.1.2" actix-router = "0.1.2"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-http = "0.3.0-alpha.1" actix-http = "0.3.0-alpha.2"
bytes = "0.4" bytes = "0.4"
futures = "0.3.1" futures = "0.3.1"
@ -32,7 +32,7 @@ pin-project = "0.4.6"
log = "0.4" log = "0.4"
[dev-dependencies] [dev-dependencies]
actix-server = { version = "0.8.0-alpha.1" } actix-server = { version = "1.0.0-alpha.2" }
actix-connect = { version = "0.3.0-alpha.1", features=["openssl"] } actix-connect = { version = "1.0.0-alpha.2", features=["openssl"] }
actix-http-test = { version = "0.3.0-alpha.1", features=["openssl"] } actix-http-test = { version = "0.3.0-alpha.2", features=["openssl"] }
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-http" name = "actix-http"
version = "0.3.0-alpha.1" version = "0.3.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix http primitives" description = "Actix http primitives"
readme = "README.md" readme = "README.md"
@ -47,15 +47,15 @@ fail = ["failure"]
secure-cookies = ["ring"] secure-cookies = ["ring"]
[dependencies] [dependencies]
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
actix-connect = "1.0.0-alpha.1" actix-connect = "1.0.0-alpha.2"
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-threadpool = "0.2.0-alpha.1" actix-threadpool = "0.3.0"
actix-tls = { git = "https://github.com/actix/actix-net.git", optional = true } actix-tls = { version = "1.0.0-alpha.1", optional = true }
base64 = "0.10" base64 = "0.11"
bitflags = "1.0" bitflags = "1.0"
bytes = "0.4" bytes = "0.4"
copyless = "0.1.4" copyless = "0.1.4"
@ -74,7 +74,7 @@ language-tags = "0.2"
log = "0.4" log = "0.4"
mime = "0.3" mime = "0.3"
percent-encoding = "2.1" percent-encoding = "2.1"
pin-project = "0.4.5" pin-project = "0.4.6"
rand = "0.7" rand = "0.7"
regex = "1.0" regex = "1.0"
serde = "1.0" serde = "1.0"
@ -83,8 +83,6 @@ sha1 = "0.6"
slab = "0.4" slab = "0.4"
serde_urlencoded = "0.6.1" serde_urlencoded = "0.6.1"
time = "0.1.42" time = "0.1.42"
tokio-net = "=0.2.0-alpha.6"
trust-dns-resolver = { version="0.18.0-alpha.1", default-features = false } trust-dns-resolver = { version="0.18.0-alpha.1", default-features = false }
# for secure cookie # for secure cookie
@ -103,11 +101,10 @@ tokio-openssl = { version = "0.4.0-alpha.6", optional = true }
# webpki-roots = { version = "0.18", optional = true } # webpki-roots = { version = "0.18", optional = true }
[dev-dependencies] [dev-dependencies]
actix-server = { version = "0.8.0-alpha.1" } actix-server = { version = "1.0.0-alpha.2" }
actix-connect = { version = "1.0.0-alpha.1", features=["openssl"] } actix-connect = { version = "1.0.0-alpha.2", features=["openssl"] }
actix-http-test = { version = "0.3.0-alpha.1", features=["openssl"] } actix-http-test = { version = "0.3.0-alpha.2", features=["openssl"] }
#actix-tls = { version = "0.1.0-alpha.1", features=["openssl"] } actix-tls = { version = "1.0.0-alpha.1", features=["openssl"] }
actix-tls = { git = "https://github.com/actix/actix-net.git", features=["openssl"] }
env_logger = "0.6" env_logger = "0.6"
serde_derive = "1.0" serde_derive = "1.0"
open-ssl = { version="0.10", package="openssl" } open-ssl = { version="0.10", package="openssl" }

View File

@ -6,10 +6,10 @@ use actix_codec::{AsyncRead, AsyncWrite};
use actix_connect::{ use actix_connect::{
default_connector, Connect as TcpConnect, Connection as TcpConnection, default_connector, Connect as TcpConnect, Connection as TcpConnection,
}; };
use actix_rt::net::TcpStream;
use actix_service::{apply_fn, Service}; use actix_service::{apply_fn, Service};
use actix_utils::timeout::{TimeoutError, TimeoutService}; use actix_utils::timeout::{TimeoutError, TimeoutService};
use http::Uri; use http::Uri;
use tokio_net::tcp::TcpStream;
use super::connection::Connection; use super::connection::Connection;
use super::error::ConnectError; use super::error::ConnectError;

View File

@ -21,7 +21,7 @@ pub struct Decoder<S> {
decoder: Option<ContentDecoder>, decoder: Option<ContentDecoder>,
stream: S, stream: S,
eof: bool, eof: bool,
fut: Option<CpuFuture<Result<(Option<Bytes>, ContentDecoder), io::Error>>>, fut: Option<CpuFuture<(Option<Bytes>, ContentDecoder), io::Error>>,
} }
impl<S> Decoder<S> impl<S> Decoder<S>
@ -85,8 +85,7 @@ where
loop { loop {
if let Some(ref mut fut) = self.fut { if let Some(ref mut fut) = self.fut {
let (chunk, decoder) = match ready!(Pin::new(fut).poll(cx)) { let (chunk, decoder) = match ready!(Pin::new(fut).poll(cx)) {
Ok(Ok(item)) => item, Ok(item) => item,
Ok(Err(e)) => return Poll::Ready(Some(Err(e.into()))),
Err(e) => return Poll::Ready(Some(Err(e.into()))), Err(e) => return Poll::Ready(Some(Err(e.into()))),
}; };
self.decoder = Some(decoder); self.decoder = Some(decoder);

View File

@ -24,7 +24,7 @@ pub struct Encoder<B> {
eof: bool, eof: bool,
body: EncoderBody<B>, body: EncoderBody<B>,
encoder: Option<ContentEncoder>, encoder: Option<ContentEncoder>,
fut: Option<CpuFuture<Result<ContentEncoder, io::Error>>>, fut: Option<CpuFuture<ContentEncoder, io::Error>>,
} }
impl<B: MessageBody> Encoder<B> { impl<B: MessageBody> Encoder<B> {
@ -104,8 +104,7 @@ impl<B: MessageBody> MessageBody for Encoder<B> {
if let Some(ref mut fut) = self.fut { if let Some(ref mut fut) = self.fut {
let mut encoder = match futures::ready!(Pin::new(fut).poll(cx)) { let mut encoder = match futures::ready!(Pin::new(fut).poll(cx)) {
Ok(Ok(item)) => item, Ok(item) => item,
Ok(Err(e)) => return Poll::Ready(Some(Err(e.into()))),
Err(e) => return Poll::Ready(Some(Err(e.into()))), Err(e) => return Poll::Ready(Some(Err(e.into()))),
}; };
let chunk = encoder.take(); let chunk = encoder.take();

View File

@ -6,6 +6,7 @@ use std::str::Utf8Error;
use std::string::FromUtf8Error; use std::string::FromUtf8Error;
use std::{fmt, io, result}; use std::{fmt, io, result};
pub use actix_threadpool::BlockingError;
use actix_utils::timeout::TimeoutError; use actix_utils::timeout::TimeoutError;
use bytes::BytesMut; use bytes::BytesMut;
use derive_more::{Display, From}; use derive_more::{Display, From};
@ -197,6 +198,9 @@ impl ResponseError for DeError {
/// `InternalServerError` for `Canceled` /// `InternalServerError` for `Canceled`
impl ResponseError for Canceled {} impl ResponseError for Canceled {}
/// `InternalServerError` for `BlockingError`
impl<E: fmt::Debug> ResponseError for BlockingError<E> {}
/// Return `BAD_REQUEST` for `Utf8Error` /// Return `BAD_REQUEST` for `Utf8Error`
impl ResponseError for Utf8Error { impl ResponseError for Utf8Error {
fn status_code(&self) -> StatusCode { fn status_code(&self) -> StatusCode {
@ -359,12 +363,15 @@ impl From<io::Error> for PayloadError {
} }
} }
impl From<Canceled> for PayloadError { impl From<BlockingError<io::Error>> for PayloadError {
fn from(_: Canceled) -> Self { fn from(err: BlockingError<io::Error>) -> Self {
PayloadError::Io(io::Error::new( match err {
BlockingError::Error(e) => PayloadError::Io(e),
BlockingError::Canceled => PayloadError::Io(io::Error::new(
io::ErrorKind::Other, io::ErrorKind::Other,
"Operation is canceled", "Operation is canceled",
)) )),
}
} }
} }

View File

@ -17,14 +17,14 @@ name = "actix_identity"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = { version = "2.0.0-alpha.1", default-features = false, features = ["secure-cookies"] } actix-web = { version = "2.0.0-alpha.2", default-features = false, features = ["secure-cookies"] }
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
futures = "0.3.1" futures = "0.3.1"
serde = "1.0" serde = "1.0"
serde_json = "1.0" serde_json = "1.0"
time = "0.1.42" time = "0.1.42"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-http = "0.3.0-alpha.1" actix-http = "0.3.0-alpha.2"
bytes = "0.4" bytes = "0.4"

View File

@ -18,9 +18,9 @@ name = "actix_multipart"
path = "src/lib.rs" path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = { version = "2.0.0-alpha.1", default-features = false } actix-web = { version = "2.0.0-alpha.2", default-features = false }
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"
bytes = "0.4" bytes = "0.4"
derive_more = "0.99.2" derive_more = "0.99.2"
httparse = "1.3" httparse = "1.3"
@ -31,5 +31,5 @@ time = "0.1"
twoway = "0.2" twoway = "0.2"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-http = "0.3.0-alpha.1" actix-http = "0.3.0-alpha.2"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-session" name = "actix-session"
version = "0.3.0-alpha.1" version = "0.3.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Session for actix web framework." description = "Session for actix web framework."
readme = "README.md" readme = "README.md"
@ -24,8 +24,8 @@ default = ["cookie-session"]
cookie-session = ["actix-web/secure-cookies"] cookie-session = ["actix-web/secure-cookies"]
[dependencies] [dependencies]
actix-web = "2.0.0-alpha.1" actix-web = "2.0.0-alpha.2"
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
bytes = "0.4" bytes = "0.4"
derive_more = "0.99.2" derive_more = "0.99.2"
futures = "0.3.1" futures = "0.3.1"
@ -35,4 +35,4 @@ serde_json = "1.0"
time = "0.1.42" time = "0.1.42"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-web-codegen" name = "actix-web-codegen"
version = "0.2.0-alpha.1" version = "0.2.0-alpha.2"
description = "Actix web proc macros" description = "Actix web proc macros"
readme = "README.md" readme = "README.md"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
@ -17,8 +17,8 @@ syn = { version = "^1", features = ["full", "parsing"] }
proc-macro2 = "^1" proc-macro2 = "^1"
[dev-dependencies] [dev-dependencies]
actix-rt = { version = "1.0.0-alpha.1" } actix-rt = { version = "1.0.0-alpha.2" }
actix-web = { version = "2.0.0-alpha.1" } actix-web = { version = "2.0.0-alpha.2" }
actix-http = { version = "0.3.0-alpha.1", features=["openssl"] } actix-http = { version = "0.3.0-alpha.2", features=["openssl"] }
actix-http-test = { version = "0.3.0-alpha.1", features=["openssl"] } actix-http-test = { version = "0.3.0-alpha.2", features=["openssl"] }
futures = { version = "0.3.1" } futures = { version = "0.3.1" }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "awc" name = "awc"
version = "0.3.0-alpha.1" version = "0.3.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix http client." description = "Actix http client."
readme = "README.md" readme = "README.md"
@ -42,10 +42,10 @@ flate2-zlib = ["actix-http/flate2-zlib"]
flate2-rust = ["actix-http/flate2-rust"] flate2-rust = ["actix-http/flate2-rust"]
[dependencies] [dependencies]
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-http = "0.3.0-alpha.1" actix-http = "0.3.0-alpha.2"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
base64 = "0.10.1" base64 = "0.10.1"
bytes = "0.4" bytes = "0.4"
@ -62,12 +62,12 @@ open-ssl = { version="0.10", package="openssl", optional = true }
# rust-tls = { version = "0.16.0", package="rustls", optional = true, features = ["dangerous_configuration"] } # rust-tls = { version = "0.16.0", package="rustls", optional = true, features = ["dangerous_configuration"] }
[dev-dependencies] [dev-dependencies]
actix-connect = { version = "1.0.0-alpha.1", features=["openssl"] } actix-connect = { version = "1.0.0-alpha.2", features=["openssl"] }
actix-web = { version = "2.0.0-alpha.1", features=["openssl"] } actix-web = { version = "2.0.0-alpha.2", features=["openssl"] }
actix-http = { version = "0.3.0-alpha.1", features=["openssl"] } actix-http = { version = "0.3.0-alpha.2", features=["openssl"] }
actix-http-test = { version = "0.3.0-alpha.1", features=["openssl"] } actix-http-test = { version = "0.3.0-alpha.2", features=["openssl"] }
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"
actix-server = { version = "0.8.0-alpha.2" } actix-server = { version = "1.0.0-alpha.2" }
#actix-tls = { version = "0.1.0-alpha.1", features=["openssl"] } #actix-tls = { version = "0.1.0-alpha.1", features=["openssl"] }
brotli2 = { version="0.3.2" } brotli2 = { version="0.3.2" }
flate2 = { version="1.0.2" } flate2 = { version="1.0.2" }

View File

@ -667,7 +667,7 @@ mod tests {
async fn async_with_block() -> Result<HttpResponse, Error> { async fn async_with_block() -> Result<HttpResponse, Error> {
let res = web::block(move || Some(4usize).ok_or("wrong")).await; let res = web::block(move || Some(4usize).ok_or("wrong")).await;
match res? { match res {
Ok(value) => Ok(HttpResponse::Ok() Ok(value) => Ok(HttpResponse::Ok()
.content_type("text/plain") .content_type("text/plain")
.body(format!("Async with block value: {}", value))), .body(format!("Async with block value: {}", value))),

View File

@ -6,6 +6,7 @@ pub use actix_http::Response as HttpResponse;
pub use bytes::{Bytes, BytesMut}; pub use bytes::{Bytes, BytesMut};
pub use futures::channel::oneshot::Canceled; pub use futures::channel::oneshot::Canceled;
use crate::error::BlockingError;
use crate::extract::FromRequest; use crate::extract::FromRequest;
use crate::handler::Factory; use crate::handler::Factory;
use crate::resource::Resource; use crate::resource::Resource;
@ -274,10 +275,11 @@ pub fn service(path: &str) -> WebService {
/// Execute blocking function on a thread pool, returns future that resolves /// Execute blocking function on a thread pool, returns future that resolves
/// to result of the function execution. /// to result of the function execution.
pub fn block<F, R>(f: F) -> impl Future<Output = Result<R, Canceled>> pub async fn block<F, I, E>(f: F) -> Result<I, BlockingError<E>>
where where
F: FnOnce() -> R + Send + 'static, F: FnOnce() -> Result<I, E> + Send + 'static,
R: Send + 'static, I: Send + 'static,
E: Send + std::fmt::Debug + 'static,
{ {
actix_threadpool::run(f) actix_threadpool::run(f).await
} }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-http-test" name = "actix-http-test"
version = "0.3.0-alpha.1" version = "0.3.0-alpha.2"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix http test server" description = "Actix http test server"
readme = "README.md" readme = "README.md"
@ -30,16 +30,16 @@ default = []
openssl = ["open-ssl", "awc/openssl", ] # "actix-tls/openssl"] openssl = ["open-ssl", "awc/openssl", ] # "actix-tls/openssl"]
[dependencies] [dependencies]
actix-service = "1.0.0-alpha.1" actix-service = "1.0.0-alpha.2"
actix-codec = "0.2.0-alpha.1" actix-codec = "0.2.0-alpha.2"
actix-connect = "1.0.0-alpha.1" actix-connect = "1.0.0-alpha.2"
actix-utils = "0.5.0-alpha.1" actix-utils = "1.0.0-alpha.2"
actix-rt = "1.0.0-alpha.1" actix-rt = "1.0.0-alpha.2"
actix-server = "0.8.0-alpha.1" actix-server = "1.0.0-alpha.2"
actix-testing = "0.3.0-alpha.1" actix-testing = "1.0.0-alpha.2"
awc = "0.3.0-alpha.1" awc = "0.3.0-alpha.2"
base64 = "0.10" base64 = "0.11"
bytes = "0.4" bytes = "0.4"
futures = "0.3.1" futures = "0.3.1"
http = "0.1.8" http = "0.1.8"
@ -52,9 +52,8 @@ sha1 = "0.6"
slab = "0.4" slab = "0.4"
serde_urlencoded = "0.6.1" serde_urlencoded = "0.6.1"
time = "0.1" time = "0.1"
tokio-net = "0.2.0-alpha.6"
open-ssl = { version="0.10", package="openssl", optional = true } open-ssl = { version="0.10", package="openssl", optional = true }
[dev-dependencies] [dev-dependencies]
actix-web = "2.0.0-alpha.1" actix-web = "2.0.0-alpha.2"
actix-http = "0.3.0-alpha.1" actix-http = "0.3.0-alpha.2"

View File

@ -3,14 +3,13 @@ use std::sync::mpsc;
use std::{net, thread, time}; use std::{net, thread, time};
use actix_codec::{AsyncRead, AsyncWrite, Framed}; use actix_codec::{AsyncRead, AsyncWrite, Framed};
use actix_rt::System; use actix_rt::{net::TcpStream, System};
use actix_server::{Server, ServiceFactory}; use actix_server::{Server, ServiceFactory};
use awc::{error::PayloadError, ws, Client, ClientRequest, ClientResponse, Connector}; use awc::{error::PayloadError, ws, Client, ClientRequest, ClientResponse, Connector};
use bytes::Bytes; use bytes::Bytes;
use futures::Stream; use futures::Stream;
use http::Method; use http::Method;
use net2::TcpBuilder; use net2::TcpBuilder;
use tokio_net::tcp::TcpStream;
pub use actix_testing::*; pub use actix_testing::*;