mirror of https://github.com/fafhrd91/actix-web
Merge branch 'master' into fix-multipart-boundary-master
This commit is contained in:
commit
715799f9db
29
Cargo.toml
29
Cargo.toml
|
@ -60,21 +60,21 @@ secure-cookies = ["actix-http/secure-cookies"]
|
||||||
fail = ["actix-http/fail"]
|
fail = ["actix-http/fail"]
|
||||||
|
|
||||||
# openssl
|
# openssl
|
||||||
openssl = ["open-ssl", "actix-tls/openssl", "awc/openssl"]
|
openssl = ["actix-tls/openssl", "awc/openssl"]
|
||||||
|
|
||||||
# rustls
|
# rustls
|
||||||
rustls = ["rust-tls", "actix-tls/rustls", "awc/rustls"]
|
rustls = ["actix-tls/rustls", "awc/rustls"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.2.0-alpha.3"
|
actix-codec = "0.2.0"
|
||||||
actix-service = "1.0.0-alpha.4"
|
actix-service = "1.0.0"
|
||||||
actix-utils = "1.0.0-alpha.3"
|
actix-utils = "1.0.1"
|
||||||
actix-router = "0.2.0"
|
actix-router = "0.2.0"
|
||||||
actix-rt = "1.0.0-alpha.3"
|
actix-rt = "1.0.0"
|
||||||
actix-server = "1.0.0-alpha.4"
|
actix-server = "1.0.0"
|
||||||
actix-testing = "1.0.0-alpha.3"
|
actix-testing = "1.0.0"
|
||||||
actix-threadpool = "0.3.0"
|
actix-threadpool = "0.3.0"
|
||||||
actix-tls = { version = "1.0.0-alpha.3" }
|
actix-tls = "1.0.0"
|
||||||
|
|
||||||
actix-web-codegen = "0.2.0-alpha.2"
|
actix-web-codegen = "0.2.0-alpha.2"
|
||||||
actix-http = "1.0.0-alpha.4"
|
actix-http = "1.0.0-alpha.4"
|
||||||
|
@ -88,7 +88,6 @@ fxhash = "0.2.1"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
net2 = "0.2.33"
|
net2 = "0.2.33"
|
||||||
parking_lot = "0.9"
|
|
||||||
pin-project = "0.4.6"
|
pin-project = "0.4.6"
|
||||||
regex = "1.3"
|
regex = "1.3"
|
||||||
serde = { version = "1.0", features=["derive"] }
|
serde = { version = "1.0", features=["derive"] }
|
||||||
|
@ -97,19 +96,17 @@ serde_urlencoded = "0.6.1"
|
||||||
time = "0.1.42"
|
time = "0.1.42"
|
||||||
url = "2.1"
|
url = "2.1"
|
||||||
|
|
||||||
# ssl support
|
|
||||||
open-ssl = { version="0.10", package="openssl", optional = true }
|
|
||||||
rust-tls = { version = "0.16", package="rustls", optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# actix = "0.8.3"
|
# actix = "0.8.3"
|
||||||
actix-connect = "1.0.0-alpha.3"
|
actix-connect = "1.0.0"
|
||||||
actix-http-test = "1.0.0-alpha.3"
|
actix-http-test = "1.0.0-alpha.3"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
brotli = "3.3.0"
|
brotli = "3.3.0"
|
||||||
flate2 = "1.0.2"
|
flate2 = "1.0.2"
|
||||||
|
open-ssl = { version="0.10", package = "openssl" }
|
||||||
|
rust_tls = { version = "0.16.0", package = "rustls" }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
@ -126,4 +123,4 @@ actix-identity = { path = "actix-identity" }
|
||||||
actix-session = { path = "actix-session" }
|
actix-session = { path = "actix-session" }
|
||||||
actix-files = { path = "actix-files" }
|
actix-files = { path = "actix-files" }
|
||||||
actix-multipart = { path = "actix-multipart" }
|
actix-multipart = { path = "actix-multipart" }
|
||||||
awc = { path = "awc" }
|
awc = { path = "awc" }
|
|
@ -18,9 +18,9 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "2.0.0-alpha.3"
|
actix-web = "2.0.0-alpha.3"
|
||||||
actix-service = "1.0.0-alpha.3"
|
actix-service = "1.0.0"
|
||||||
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.3"
|
actix-rt = "1.0.0"
|
||||||
|
|
|
@ -20,7 +20,7 @@ path = "src/lib.rs"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "2.0.0-alpha.3", default-features = false }
|
actix-web = { version = "2.0.0-alpha.3", default-features = false }
|
||||||
actix-http = "1.0.0-alpha.3"
|
actix-http = "1.0.0-alpha.3"
|
||||||
actix-service = "1.0.0-alpha.3"
|
actix-service = "1.0.0"
|
||||||
bitflags = "1"
|
bitflags = "1"
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
||||||
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.3"
|
actix-rt = "1.0.0"
|
||||||
actix-web = { version = "2.0.0-alpha.3", features=["openssl"] }
|
actix-web = { version = "2.0.0-alpha.3", features=["openssl"] }
|
||||||
|
|
|
@ -20,10 +20,10 @@ name = "actix_framed"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.2.0-alpha.3"
|
actix-codec = "0.2.0"
|
||||||
actix-service = "1.0.0-alpha.3"
|
actix-service = "1.0.0"
|
||||||
actix-router = "0.2.0"
|
actix-router = "0.2.0"
|
||||||
actix-rt = "1.0.0-alpha.3"
|
actix-rt = "1.0.0"
|
||||||
actix-http = "1.0.0-alpha.3"
|
actix-http = "1.0.0-alpha.3"
|
||||||
|
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
||||||
|
@ -32,7 +32,7 @@ pin-project = "0.4.6"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-server = { version = "1.0.0-alpha.3" }
|
actix-server = "1.0.0"
|
||||||
actix-connect = { version = "1.0.0-alpha.3", features=["openssl"] }
|
actix-connect = { version = "1.0.0", features=["openssl"] }
|
||||||
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
||||||
actix-utils = "1.0.0-alpha.3"
|
actix-utils = "1.0.0"
|
||||||
|
|
|
@ -2,7 +2,7 @@ use actix_codec::{AsyncRead, AsyncWrite};
|
||||||
use actix_http::{body, http::StatusCode, ws, Error, HttpService, Response};
|
use actix_http::{body, http::StatusCode, ws, Error, HttpService, Response};
|
||||||
use actix_http_test::TestServer;
|
use actix_http_test::TestServer;
|
||||||
use actix_service::{pipeline_factory, IntoServiceFactory, ServiceFactory};
|
use actix_service::{pipeline_factory, IntoServiceFactory, ServiceFactory};
|
||||||
use actix_utils::framed::FramedTransport;
|
use actix_utils::framed::Dispatcher;
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures::{future, SinkExt, StreamExt};
|
use futures::{future, SinkExt, StreamExt};
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ async fn ws_service<T: AsyncRead + AsyncWrite>(
|
||||||
.send((res, body::BodySize::None).into())
|
.send((res, body::BodySize::None).into())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
FramedTransport::new(framed.into_framed(ws::Codec::new()), service)
|
Dispatcher::new(framed.into_framed(ws::Codec::new()), service)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
# Changes
|
# Changes
|
||||||
|
|
||||||
|
## [1.0.0-alpha.5] - 2019-12-09
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Check `Upgrade` service readiness before calling it
|
||||||
|
|
||||||
|
* Fix buffer remaining capacity calcualtion
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "actix-http"
|
name = "actix-http"
|
||||||
version = "1.0.0-alpha.4"
|
version = "1.0.0-alpha.6"
|
||||||
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"
|
||||||
|
@ -44,13 +44,13 @@ fail = ["failure"]
|
||||||
secure-cookies = ["ring"]
|
secure-cookies = ["ring"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-service = "1.0.0-alpha.4"
|
actix-service = "1.0.0"
|
||||||
actix-codec = "0.2.0-alpha.3"
|
actix-codec = "0.2.0"
|
||||||
actix-connect = "1.0.0-alpha.3"
|
actix-connect = "1.0.0"
|
||||||
actix-utils = "1.0.0-alpha.3"
|
actix-utils = "1.0.1"
|
||||||
actix-rt = "1.0.0-alpha.3"
|
actix-rt = "1.0.0"
|
||||||
actix-threadpool = "0.3.0"
|
actix-threadpool = "0.3.0"
|
||||||
actix-tls = { version = "1.0.0-alpha.3", optional = true }
|
actix-tls = { version = "1.0.0", optional = true }
|
||||||
|
|
||||||
base64 = "0.11"
|
base64 = "0.11"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
|
@ -92,10 +92,10 @@ flate2 = { version="1.0.7", optional = true, default-features = false }
|
||||||
failure = { version = "0.1.5", optional = true }
|
failure = { version = "0.1.5", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-server = { version = "1.0.0-alpha.4" }
|
actix-server = "1.0.0"
|
||||||
actix-connect = { version = "1.0.0-alpha.3", features=["openssl"] }
|
actix-connect = { version = "1.0.0", features=["openssl"] }
|
||||||
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
||||||
actix-tls = { version = "1.0.0-alpha.3", features=["openssl"] }
|
actix-tls = { version = "1.0.0", 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" }
|
||||||
|
|
|
@ -8,7 +8,7 @@ use actix_codec::{AsyncRead, AsyncWrite, Decoder, Encoder, Framed, FramedParts};
|
||||||
use actix_rt::time::{delay_until, Delay, Instant};
|
use actix_rt::time::{delay_until, Delay, Instant};
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use bytes::{BufMut, BytesMut};
|
use bytes::BytesMut;
|
||||||
use log::{error, trace};
|
use log::{error, trace};
|
||||||
|
|
||||||
use crate::body::{Body, BodySize, MessageBody, ResponseBody};
|
use crate::body::{Body, BodySize, MessageBody, ResponseBody};
|
||||||
|
@ -66,6 +66,7 @@ where
|
||||||
U::Error: fmt::Display,
|
U::Error: fmt::Display,
|
||||||
{
|
{
|
||||||
Normal(InnerDispatcher<T, S, B, X, U>),
|
Normal(InnerDispatcher<T, S, B, X, U>),
|
||||||
|
UpgradeReadiness(InnerDispatcher<T, S, B, X, U>, Request),
|
||||||
Upgrade(U::Future),
|
Upgrade(U::Future),
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
@ -750,8 +751,10 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if inner.write_buf.remaining_mut() < LW_BUFFER_SIZE {
|
let remaining =
|
||||||
inner.write_buf.reserve(HW_BUFFER_SIZE);
|
inner.write_buf.capacity() - inner.write_buf.len();
|
||||||
|
if remaining < LW_BUFFER_SIZE {
|
||||||
|
inner.write_buf.reserve(HW_BUFFER_SIZE - remaining);
|
||||||
}
|
}
|
||||||
let result = inner.poll_response(cx)?;
|
let result = inner.poll_response(cx)?;
|
||||||
let drain = result == PollResponse::DrainWriteBuf;
|
let drain = result == PollResponse::DrainWriteBuf;
|
||||||
|
@ -761,16 +764,8 @@ where
|
||||||
if let DispatcherState::Normal(inner) =
|
if let DispatcherState::Normal(inner) =
|
||||||
std::mem::replace(&mut self.inner, DispatcherState::None)
|
std::mem::replace(&mut self.inner, DispatcherState::None)
|
||||||
{
|
{
|
||||||
let mut parts = FramedParts::with_read_buf(
|
self.inner =
|
||||||
inner.io,
|
DispatcherState::UpgradeReadiness(inner, req);
|
||||||
inner.codec,
|
|
||||||
inner.read_buf,
|
|
||||||
);
|
|
||||||
parts.write_buf = inner.write_buf;
|
|
||||||
let framed = Framed::from_parts(parts);
|
|
||||||
self.inner = DispatcherState::Upgrade(
|
|
||||||
inner.upgrade.unwrap().call((req, framed)),
|
|
||||||
);
|
|
||||||
return self.poll(cx);
|
return self.poll(cx);
|
||||||
} else {
|
} else {
|
||||||
panic!()
|
panic!()
|
||||||
|
@ -820,6 +815,35 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DispatcherState::UpgradeReadiness(ref mut inner, _) => {
|
||||||
|
let upgrade = inner.upgrade.as_mut().unwrap();
|
||||||
|
match upgrade.poll_ready(cx) {
|
||||||
|
Poll::Ready(Ok(_)) => {
|
||||||
|
if let DispatcherState::UpgradeReadiness(inner, req) =
|
||||||
|
std::mem::replace(&mut self.inner, DispatcherState::None)
|
||||||
|
{
|
||||||
|
let mut parts = FramedParts::with_read_buf(
|
||||||
|
inner.io,
|
||||||
|
inner.codec,
|
||||||
|
inner.read_buf,
|
||||||
|
);
|
||||||
|
parts.write_buf = inner.write_buf;
|
||||||
|
let framed = Framed::from_parts(parts);
|
||||||
|
self.inner = DispatcherState::Upgrade(
|
||||||
|
inner.upgrade.unwrap().call((req, framed)),
|
||||||
|
);
|
||||||
|
self.poll(cx)
|
||||||
|
} else {
|
||||||
|
panic!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Poll::Pending => Poll::Pending,
|
||||||
|
Poll::Ready(Err(e)) => {
|
||||||
|
error!("Upgrade handler readiness check error: {}", e);
|
||||||
|
Poll::Ready(Err(DispatchError::Upgrade))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
DispatcherState::Upgrade(ref mut fut) => {
|
DispatcherState::Upgrade(ref mut fut) => {
|
||||||
unsafe { Pin::new_unchecked(fut) }.poll(cx).map_err(|e| {
|
unsafe { Pin::new_unchecked(fut) }.poll(cx).map_err(|e| {
|
||||||
error!("Upgrade handler error: {}", e);
|
error!("Upgrade handler error: {}", e);
|
||||||
|
@ -841,8 +865,9 @@ where
|
||||||
{
|
{
|
||||||
let mut read_some = false;
|
let mut read_some = false;
|
||||||
loop {
|
loop {
|
||||||
if buf.remaining_mut() < LW_BUFFER_SIZE {
|
let remaining = buf.capacity() - buf.len();
|
||||||
buf.reserve(HW_BUFFER_SIZE);
|
if remaining < LW_BUFFER_SIZE {
|
||||||
|
buf.reserve(HW_BUFFER_SIZE - remaining);
|
||||||
}
|
}
|
||||||
|
|
||||||
match read(cx, io, buf) {
|
match read(cx, io, buf) {
|
||||||
|
|
|
@ -4,19 +4,19 @@ use std::task::{Context, Poll};
|
||||||
|
|
||||||
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
||||||
use actix_service::{IntoService, Service};
|
use actix_service::{IntoService, Service};
|
||||||
use actix_utils::framed::{FramedTransport, FramedTransportError};
|
use actix_utils::framed;
|
||||||
|
|
||||||
use super::{Codec, Frame, Message};
|
use super::{Codec, Frame, Message};
|
||||||
|
|
||||||
pub struct Transport<S, T>
|
pub struct Dispatcher<S, T>
|
||||||
where
|
where
|
||||||
S: Service<Request = Frame, Response = Message> + 'static,
|
S: Service<Request = Frame, Response = Message> + 'static,
|
||||||
T: AsyncRead + AsyncWrite,
|
T: AsyncRead + AsyncWrite,
|
||||||
{
|
{
|
||||||
inner: FramedTransport<S, T, Codec>,
|
inner: framed::Dispatcher<S, T, Codec>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, T> Transport<S, T>
|
impl<S, T> Dispatcher<S, T>
|
||||||
where
|
where
|
||||||
T: AsyncRead + AsyncWrite,
|
T: AsyncRead + AsyncWrite,
|
||||||
S: Service<Request = Frame, Response = Message>,
|
S: Service<Request = Frame, Response = Message>,
|
||||||
|
@ -24,26 +24,26 @@ where
|
||||||
S::Error: 'static,
|
S::Error: 'static,
|
||||||
{
|
{
|
||||||
pub fn new<F: IntoService<S>>(io: T, service: F) -> Self {
|
pub fn new<F: IntoService<S>>(io: T, service: F) -> Self {
|
||||||
Transport {
|
Dispatcher {
|
||||||
inner: FramedTransport::new(Framed::new(io, Codec::new()), service),
|
inner: framed::Dispatcher::new(Framed::new(io, Codec::new()), service),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with<F: IntoService<S>>(framed: Framed<T, Codec>, service: F) -> Self {
|
pub fn with<F: IntoService<S>>(framed: Framed<T, Codec>, service: F) -> Self {
|
||||||
Transport {
|
Dispatcher {
|
||||||
inner: FramedTransport::new(framed, service),
|
inner: framed::Dispatcher::new(framed, service),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S, T> Future for Transport<S, T>
|
impl<S, T> Future for Dispatcher<S, T>
|
||||||
where
|
where
|
||||||
T: AsyncRead + AsyncWrite,
|
T: AsyncRead + AsyncWrite,
|
||||||
S: Service<Request = Frame, Response = Message>,
|
S: Service<Request = Frame, Response = Message>,
|
||||||
S::Future: 'static,
|
S::Future: 'static,
|
||||||
S::Error: 'static,
|
S::Error: 'static,
|
||||||
{
|
{
|
||||||
type Output = Result<(), FramedTransportError<S::Error, Codec>>;
|
type Output = Result<(), framed::DispatcherError<S::Error, Codec>>;
|
||||||
|
|
||||||
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
|
||||||
Pin::new(&mut self.inner).poll(cx)
|
Pin::new(&mut self.inner).poll(cx)
|
|
@ -13,15 +13,15 @@ use crate::message::RequestHead;
|
||||||
use crate::response::{Response, ResponseBuilder};
|
use crate::response::{Response, ResponseBuilder};
|
||||||
|
|
||||||
mod codec;
|
mod codec;
|
||||||
|
mod dispatcher;
|
||||||
mod frame;
|
mod frame;
|
||||||
mod mask;
|
mod mask;
|
||||||
mod proto;
|
mod proto;
|
||||||
mod transport;
|
|
||||||
|
|
||||||
pub use self::codec::{Codec, Frame, Message};
|
pub use self::codec::{Codec, Frame, Message};
|
||||||
|
pub use self::dispatcher::Dispatcher;
|
||||||
pub use self::frame::Parser;
|
pub use self::frame::Parser;
|
||||||
pub use self::proto::{hash_key, CloseCode, CloseReason, OpCode};
|
pub use self::proto::{hash_key, CloseCode, CloseReason, OpCode};
|
||||||
pub use self::transport::Transport;
|
|
||||||
|
|
||||||
/// Websocket protocol errors
|
/// Websocket protocol errors
|
||||||
#[derive(Debug, Display, From)]
|
#[derive(Debug, Display, From)]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
use actix_codec::{AsyncRead, AsyncWrite, Framed};
|
||||||
use actix_http::{body, h1, ws, Error, HttpService, Request, Response};
|
use actix_http::{body, h1, ws, Error, HttpService, Request, Response};
|
||||||
use actix_http_test::TestServer;
|
use actix_http_test::TestServer;
|
||||||
use actix_utils::framed::FramedTransport;
|
use actix_utils::framed::Dispatcher;
|
||||||
use bytes::BytesMut;
|
use bytes::BytesMut;
|
||||||
use futures::future;
|
use futures::future;
|
||||||
use futures::{SinkExt, StreamExt};
|
use futures::{SinkExt, StreamExt};
|
||||||
|
@ -16,7 +16,7 @@ async fn ws_service<T: AsyncRead + AsyncWrite + Unpin>(
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
FramedTransport::new(framed.into_framed(ws::Codec::new()), service)
|
Dispatcher::new(framed.into_framed(ws::Codec::new()), service)
|
||||||
.await
|
.await
|
||||||
.map_err(|_| panic!())
|
.map_err(|_| panic!())
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,13 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "2.0.0-alpha.3", default-features = false, features = ["secure-cookies"] }
|
actix-web = { version = "2.0.0-alpha.3", default-features = false, features = ["secure-cookies"] }
|
||||||
actix-service = "1.0.0-alpha.3"
|
actix-service = "1.0.0"
|
||||||
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.3"
|
actix-rt = "1.0.0"
|
||||||
actix-http = "1.0.0-alpha.3"
|
actix-http = "1.0.0-alpha.3"
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
|
@ -19,8 +19,8 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = { version = "2.0.0-alpha.3", default-features = false }
|
actix-web = { version = "2.0.0-alpha.3", default-features = false }
|
||||||
actix-service = "1.0.0-alpha.3"
|
actix-service = "1.0.0"
|
||||||
actix-utils = "1.0.0-alpha.3"
|
actix-utils = "1.0.0"
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
||||||
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.3"
|
actix-rt = "1.0.0"
|
||||||
actix-http = "1.0.0-alpha.3"
|
actix-http = "1.0.0-alpha.3"
|
|
@ -25,7 +25,7 @@ cookie-session = ["actix-web/secure-cookies"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "2.0.0-alpha.3"
|
actix-web = "2.0.0-alpha.3"
|
||||||
actix-service = "1.0.0-alpha.3"
|
actix-service = "1.0.0"
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
futures = "0.3.1"
|
futures = "0.3.1"
|
||||||
|
@ -34,4 +34,4 @@ serde_json = "1.0"
|
||||||
time = "0.1.42"
|
time = "0.1.42"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-rt = "1.0.0-alpha.3"
|
actix-rt = "1.0.0"
|
||||||
|
|
|
@ -39,10 +39,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.3"
|
actix-codec = "0.2.0"
|
||||||
actix-service = "1.0.0-alpha.4"
|
actix-service = "1.0.0"
|
||||||
actix-http = "1.0.0-alpha.4"
|
actix-http = "1.0.0-alpha.4"
|
||||||
actix-rt = "1.0.0-alpha.3"
|
actix-rt = "1.0.0"
|
||||||
|
|
||||||
base64 = "0.11"
|
base64 = "0.11"
|
||||||
bytes = "0.5.2"
|
bytes = "0.5.2"
|
||||||
|
@ -59,13 +59,13 @@ 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.3", features=["openssl"] }
|
actix-connect = { version = "1.0.0", features=["openssl"] }
|
||||||
actix-web = { version = "2.0.0-alpha.3", features=["openssl"] }
|
actix-web = { version = "2.0.0-alpha.3", features=["openssl"] }
|
||||||
actix-http = { version = "1.0.0-alpha.4", features=["openssl"] }
|
actix-http = { version = "1.0.0-alpha.4", features=["openssl"] }
|
||||||
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
actix-http-test = { version = "1.0.0-alpha.3", features=["openssl"] }
|
||||||
actix-utils = "1.0.0-alpha.3"
|
actix-utils = "1.0.0"
|
||||||
actix-server = { version = "1.0.0-alpha.4" }
|
actix-server = "1.0.0"
|
||||||
actix-tls = { version = "1.0.0-alpha.3", features=["openssl", "rustls"] }
|
actix-tls = { version = "1.0.0", features=["openssl", "rustls"] }
|
||||||
brotli = "3.3.0"
|
brotli = "3.3.0"
|
||||||
flate2 = { version="1.0.2" }
|
flate2 = { version="1.0.2" }
|
||||||
env_logger = "0.6"
|
env_logger = "0.6"
|
||||||
|
|
|
@ -42,7 +42,7 @@ async fn test_simple() {
|
||||||
|
|
||||||
// start websocket service
|
// start websocket service
|
||||||
let framed = framed.into_framed(ws::Codec::new());
|
let framed = framed.into_framed(ws::Codec::new());
|
||||||
ws::Transport::with(framed, ws_service).await
|
ws::Dispatcher::with(framed, ws_service).await
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.finish(|_| ok::<_, Error>(Response::NotFound()))
|
.finish(|_| ok::<_, Error>(Response::NotFound()))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::sync::Arc;
|
use std::sync::{Arc, Mutex};
|
||||||
use std::{fmt, io, net};
|
use std::{fmt, io, net};
|
||||||
|
|
||||||
use actix_http::{
|
use actix_http::{
|
||||||
|
@ -8,12 +8,11 @@ use actix_http::{
|
||||||
use actix_server::{Server, ServerBuilder};
|
use actix_server::{Server, ServerBuilder};
|
||||||
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
|
use actix_service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
|
||||||
use futures::future::ok;
|
use futures::future::ok;
|
||||||
use parking_lot::Mutex;
|
|
||||||
|
|
||||||
use net2::TcpBuilder;
|
use net2::TcpBuilder;
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
use actix_tls::openssl::{SslAcceptor, SslAcceptorBuilder};
|
use actix_tls::openssl::{AlpnError, SslAcceptor, SslAcceptorBuilder};
|
||||||
#[cfg(feature = "rustls")]
|
#[cfg(feature = "rustls")]
|
||||||
use actix_tls::rustls::ServerConfig as RustlsServerConfig;
|
use actix_tls::rustls::ServerConfig as RustlsServerConfig;
|
||||||
|
|
||||||
|
@ -147,7 +146,7 @@ where
|
||||||
///
|
///
|
||||||
/// By default keep alive is set to a 5 seconds.
|
/// By default keep alive is set to a 5 seconds.
|
||||||
pub fn keep_alive<T: Into<KeepAlive>>(self, val: T) -> Self {
|
pub fn keep_alive<T: Into<KeepAlive>>(self, val: T) -> Self {
|
||||||
self.config.lock().keep_alive = val.into();
|
self.config.lock().unwrap().keep_alive = val.into();
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +160,7 @@ where
|
||||||
///
|
///
|
||||||
/// By default client timeout is set to 5000 milliseconds.
|
/// By default client timeout is set to 5000 milliseconds.
|
||||||
pub fn client_timeout(self, val: u64) -> Self {
|
pub fn client_timeout(self, val: u64) -> Self {
|
||||||
self.config.lock().client_timeout = val;
|
self.config.lock().unwrap().client_timeout = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +173,7 @@ where
|
||||||
///
|
///
|
||||||
/// By default client timeout is set to 5000 milliseconds.
|
/// By default client timeout is set to 5000 milliseconds.
|
||||||
pub fn client_shutdown(self, val: u64) -> Self {
|
pub fn client_shutdown(self, val: u64) -> Self {
|
||||||
self.config.lock().client_shutdown = val;
|
self.config.lock().unwrap().client_shutdown = val;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +245,7 @@ where
|
||||||
format!("actix-web-service-{}", addr),
|
format!("actix-web-service-{}", addr),
|
||||||
lst,
|
lst,
|
||||||
move || {
|
move || {
|
||||||
let c = cfg.lock();
|
let c = cfg.lock().unwrap();
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
|
@ -288,7 +287,7 @@ where
|
||||||
format!("actix-web-service-{}", addr),
|
format!("actix-web-service-{}", addr),
|
||||||
lst,
|
lst,
|
||||||
move || {
|
move || {
|
||||||
let c = cfg.lock();
|
let c = cfg.lock().unwrap();
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
|
@ -330,7 +329,7 @@ where
|
||||||
format!("actix-web-service-{}", addr),
|
format!("actix-web-service-{}", addr),
|
||||||
lst,
|
lst,
|
||||||
move || {
|
move || {
|
||||||
let c = cfg.lock();
|
let c = cfg.lock().unwrap();
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
.client_timeout(c.client_timeout)
|
.client_timeout(c.client_timeout)
|
||||||
|
@ -448,7 +447,7 @@ where
|
||||||
let addr = format!("actix-web-service-{:?}", lst.local_addr()?);
|
let addr = format!("actix-web-service-{:?}", lst.local_addr()?);
|
||||||
|
|
||||||
self.builder = self.builder.listen_uds(addr, lst, move || {
|
self.builder = self.builder.listen_uds(addr, lst, move || {
|
||||||
let c = cfg.lock();
|
let c = cfg.lock().unwrap();
|
||||||
pipeline_factory(|io: UnixStream| ok((io, Protocol::Http1, None))).and_then(
|
pipeline_factory(|io: UnixStream| ok((io, Protocol::Http1, None))).and_then(
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
.keep_alive(c.keep_alive)
|
.keep_alive(c.keep_alive)
|
||||||
|
@ -483,7 +482,7 @@ where
|
||||||
format!("actix-web-service-{:?}", addr.as_ref()),
|
format!("actix-web-service-{:?}", addr.as_ref()),
|
||||||
addr,
|
addr,
|
||||||
move || {
|
move || {
|
||||||
let c = cfg.lock();
|
let c = cfg.lock().unwrap();
|
||||||
pipeline_factory(|io: UnixStream| ok((io, Protocol::Http1, None)))
|
pipeline_factory(|io: UnixStream| ok((io, Protocol::Http1, None)))
|
||||||
.and_then(
|
.and_then(
|
||||||
HttpService::build()
|
HttpService::build()
|
||||||
|
@ -550,8 +549,6 @@ fn create_tcp_listener(
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
/// Configure `SslAcceptorBuilder` with custom server flags.
|
/// Configure `SslAcceptorBuilder` with custom server flags.
|
||||||
fn openssl_acceptor(mut builder: SslAcceptorBuilder) -> io::Result<SslAcceptor> {
|
fn openssl_acceptor(mut builder: SslAcceptorBuilder) -> io::Result<SslAcceptor> {
|
||||||
use open_ssl::ssl::AlpnError;
|
|
||||||
|
|
||||||
builder.set_alpn_select_callback(|_, protos| {
|
builder.set_alpn_select_callback(|_, protos| {
|
||||||
const H2: &[u8] = b"\x02h2";
|
const H2: &[u8] = b"\x02h2";
|
||||||
const H11: &[u8] = b"\x08http/1.1";
|
const H11: &[u8] = b"\x08http/1.1";
|
||||||
|
|
|
@ -30,13 +30,13 @@ 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.3"
|
actix-service = "1.0.0"
|
||||||
actix-codec = "0.2.0-alpha.3"
|
actix-codec = "0.2.0"
|
||||||
actix-connect = "1.0.0-alpha.3"
|
actix-connect = "1.0.0"
|
||||||
actix-utils = "1.0.0-alpha.3"
|
actix-utils = "1.0.0"
|
||||||
actix-rt = "1.0.0-alpha.3"
|
actix-rt = "1.0.0"
|
||||||
actix-server = "1.0.0-alpha.3"
|
actix-server = "1.0.0"
|
||||||
actix-testing = "1.0.0-alpha.3"
|
actix-testing = "1.0.0"
|
||||||
awc = "1.0.0-alpha.3"
|
awc = "1.0.0-alpha.3"
|
||||||
|
|
||||||
base64 = "0.11"
|
base64 = "0.11"
|
||||||
|
|
Loading…
Reference in New Issue