mirror of https://github.com/fafhrd91/actix-web
update deps
This commit is contained in:
parent
0c4b3fcc54
commit
bfe47b2034
|
@ -74,7 +74,7 @@ required-features = ["rustls"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-codec = "0.4.0-beta.1"
|
actix-codec = "0.4.0-beta.1"
|
||||||
actix-macros = "0.1.0"
|
actix-macros = "0.2.0"
|
||||||
actix-router = "0.2.4"
|
actix-router = "0.2.4"
|
||||||
actix-rt = "2.0.0-beta.2"
|
actix-rt = "2.0.0-beta.2"
|
||||||
actix-server = "2.0.0-beta.2"
|
actix-server = "2.0.0-beta.2"
|
||||||
|
@ -137,6 +137,8 @@ actix-server = { 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" }
|
||||||
actix-router = { git = "https://github.com/actix/actix-net.git" }
|
actix-router = { git = "https://github.com/actix/actix-net.git" }
|
||||||
|
actix-macros = { git = "https://github.com/actix/actix-net" }
|
||||||
|
actix = { git = "https://github.com/actix/actix", branch = "feat/actix-rt-2" }
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
name = "server"
|
name = "server"
|
||||||
|
|
|
@ -60,7 +60,7 @@ pub async fn test_server_with_addr<F: ServiceFactory<TcpStream>>(
|
||||||
|
|
||||||
// run server in separate thread
|
// run server in separate thread
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let sys = System::new("actix-test-server");
|
let sys = System::new();
|
||||||
let local_addr = tcp.local_addr().unwrap();
|
let local_addr = tcp.local_addr().unwrap();
|
||||||
|
|
||||||
let srv = Server::build()
|
let srv = Server::build()
|
||||||
|
|
|
@ -43,7 +43,7 @@ actors = ["actix"]
|
||||||
actix-service = "2.0.0-beta.3"
|
actix-service = "2.0.0-beta.3"
|
||||||
actix-codec = "0.4.0-beta.1"
|
actix-codec = "0.4.0-beta.1"
|
||||||
actix-utils = "3.0.0-beta.1"
|
actix-utils = "3.0.0-beta.1"
|
||||||
actix-rt = "2.0.0-beta.2"
|
actix-rt = "2.0.0-beta.3"
|
||||||
actix-tls = "3.0.0-beta.2"
|
actix-tls = "3.0.0-beta.2"
|
||||||
actix = { version = "0.11.0-beta.1", optional = true }
|
actix = { version = "0.11.0-beta.1", optional = true }
|
||||||
|
|
||||||
|
|
|
@ -326,7 +326,7 @@ where
|
||||||
{
|
{
|
||||||
if let Some(timeout) = self.config.disconnect_timeout {
|
if let Some(timeout) = self.config.disconnect_timeout {
|
||||||
if let ConnectionType::H1(io) = conn.io {
|
if let ConnectionType::H1(io) = conn.io {
|
||||||
actix_rt::spawn(CloseConnection::new(io, timeout))
|
actix_rt::spawn(CloseConnection::new(io, timeout));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -341,7 +341,7 @@ where
|
||||||
if let ConnectionType::H1(io) = io {
|
if let ConnectionType::H1(io) = io {
|
||||||
actix_rt::spawn(CloseConnection::new(
|
actix_rt::spawn(CloseConnection::new(
|
||||||
io, timeout,
|
io, timeout,
|
||||||
))
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -373,7 +373,7 @@ where
|
||||||
self.acquired -= 1;
|
self.acquired -= 1;
|
||||||
if let Some(timeout) = self.config.disconnect_timeout {
|
if let Some(timeout) = self.config.disconnect_timeout {
|
||||||
if let ConnectionType::H1(io) = io {
|
if let ConnectionType::H1(io) = io {
|
||||||
actix_rt::spawn(CloseConnection::new(io, timeout))
|
actix_rt::spawn(CloseConnection::new(io, timeout));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.check_availability();
|
self.check_availability();
|
||||||
|
@ -536,7 +536,7 @@ where
|
||||||
rx: Some(rx),
|
rx: Some(rx),
|
||||||
inner: Some(inner),
|
inner: Some(inner),
|
||||||
config,
|
config,
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,16 +150,6 @@ enum PollResponse {
|
||||||
DrainWriteBuf,
|
DrainWriteBuf,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PartialEq for PollResponse {
|
|
||||||
fn eq(&self, other: &PollResponse) -> bool {
|
|
||||||
match self {
|
|
||||||
PollResponse::DrainWriteBuf => matches!(other, PollResponse::DrainWriteBuf),
|
|
||||||
PollResponse::DoNothing => matches!(other, PollResponse::DoNothing),
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T, S, B, X, U> Dispatcher<T, S, B, X, U>
|
impl<T, S, B, X, U> Dispatcher<T, S, B, X, U>
|
||||||
where
|
where
|
||||||
T: AsyncRead + AsyncWrite + Unpin,
|
T: AsyncRead + AsyncWrite + Unpin,
|
||||||
|
@ -324,9 +314,10 @@ where
|
||||||
message: Response<()>,
|
message: Response<()>,
|
||||||
body: ResponseBody<B>,
|
body: ResponseBody<B>,
|
||||||
) -> Result<(), DispatchError> {
|
) -> Result<(), DispatchError> {
|
||||||
|
let size = body.size();
|
||||||
let mut this = self.project();
|
let mut this = self.project();
|
||||||
this.codec
|
this.codec
|
||||||
.encode(Message::Item((message, body.size())), &mut this.write_buf)
|
.encode(Message::Item((message, size)), &mut this.write_buf)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
if let Some(mut payload) = this.payload.take() {
|
if let Some(mut payload) = this.payload.take() {
|
||||||
payload.set_error(PayloadError::Incomplete(None));
|
payload.set_error(PayloadError::Incomplete(None));
|
||||||
|
@ -335,7 +326,7 @@ where
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
this.flags.set(Flags::KEEPALIVE, this.codec.keepalive());
|
this.flags.set(Flags::KEEPALIVE, this.codec.keepalive());
|
||||||
match body.size() {
|
match size {
|
||||||
BodySize::None | BodySize::Empty => this.state.set(State::None),
|
BodySize::None | BodySize::Empty => this.state.set(State::None),
|
||||||
_ => this.state.set(State::SendPayload(body)),
|
_ => this.state.set(State::SendPayload(body)),
|
||||||
};
|
};
|
||||||
|
@ -462,28 +453,28 @@ where
|
||||||
req: Request,
|
req: Request,
|
||||||
cx: &mut Context<'_>,
|
cx: &mut Context<'_>,
|
||||||
) -> Result<(), DispatchError> {
|
) -> Result<(), DispatchError> {
|
||||||
|
let mut this = self.as_mut().project();
|
||||||
|
|
||||||
// Handle `EXPECT: 100-Continue` header
|
// Handle `EXPECT: 100-Continue` header
|
||||||
if req.head().expect() {
|
if req.head().expect() {
|
||||||
// set dispatcher state so the future is pinned.
|
// set dispatcher state so the future is pinned.
|
||||||
let mut this = self.as_mut().project();
|
|
||||||
let task = this.flow.expect.call(req);
|
let task = this.flow.expect.call(req);
|
||||||
this.state.set(State::ExpectCall(task));
|
this.state.set(State::ExpectCall(task));
|
||||||
} else {
|
} else {
|
||||||
// the same as above.
|
// the same as above.
|
||||||
let mut this = self.as_mut().project();
|
|
||||||
let task = this.flow.service.call(req);
|
let task = this.flow.service.call(req);
|
||||||
this.state.set(State::ServiceCall(task));
|
this.state.set(State::ServiceCall(task));
|
||||||
};
|
};
|
||||||
|
|
||||||
// eagerly poll the future for once(or twice if expect is resolved immediately).
|
// eagerly poll the future for once(or twice if expect is resolved immediately).
|
||||||
loop {
|
loop {
|
||||||
match self.as_mut().project().state.project() {
|
match this.state.project() {
|
||||||
StateProj::ExpectCall(fut) => {
|
StateProj::ExpectCall(fut) => {
|
||||||
match fut.poll(cx) {
|
match fut.poll(cx) {
|
||||||
// expect is resolved. continue loop and poll the service call branch.
|
// expect is resolved. continue loop and poll the service call branch.
|
||||||
Poll::Ready(Ok(req)) => {
|
Poll::Ready(Ok(req)) => {
|
||||||
self.as_mut().send_continue();
|
self.as_mut().send_continue();
|
||||||
let mut this = self.as_mut().project();
|
this = self.as_mut().project();
|
||||||
let task = this.flow.service.call(req);
|
let task = this.flow.service.call(req);
|
||||||
this.state.set(State::ServiceCall(task));
|
this.state.set(State::ServiceCall(task));
|
||||||
continue;
|
continue;
|
||||||
|
@ -793,31 +784,32 @@ where
|
||||||
if remaining < LW_BUFFER_SIZE {
|
if remaining < LW_BUFFER_SIZE {
|
||||||
inner_p.write_buf.reserve(HW_BUFFER_SIZE - remaining);
|
inner_p.write_buf.reserve(HW_BUFFER_SIZE - remaining);
|
||||||
}
|
}
|
||||||
let result = inner.as_mut().poll_response(cx)?;
|
|
||||||
let drain = result == PollResponse::DrainWriteBuf;
|
|
||||||
|
|
||||||
// switch to upgrade handler
|
let drain = match inner.as_mut().poll_response(cx)? {
|
||||||
if let PollResponse::Upgrade(req) = result {
|
PollResponse::DrainWriteBuf => true,
|
||||||
let inner_p = inner.as_mut().project();
|
PollResponse::DoNothing => false,
|
||||||
let mut parts = FramedParts::with_read_buf(
|
PollResponse::Upgrade(req) => {
|
||||||
inner_p.io.take().unwrap(),
|
let inner_p = inner.as_mut().project();
|
||||||
mem::take(inner_p.codec),
|
let mut parts = FramedParts::with_read_buf(
|
||||||
mem::take(inner_p.read_buf),
|
inner_p.io.take().unwrap(),
|
||||||
);
|
mem::take(inner_p.codec),
|
||||||
parts.write_buf = mem::take(inner_p.write_buf);
|
mem::take(inner_p.read_buf),
|
||||||
let framed = Framed::from_parts(parts);
|
);
|
||||||
let upgrade = inner_p
|
parts.write_buf = mem::take(inner_p.write_buf);
|
||||||
.flow
|
let framed = Framed::from_parts(parts);
|
||||||
.upgrade
|
let upgrade = inner_p
|
||||||
.as_ref()
|
.flow
|
||||||
.unwrap()
|
.upgrade
|
||||||
.call((req, framed));
|
.as_ref()
|
||||||
self.as_mut()
|
.unwrap()
|
||||||
.project()
|
.call((req, framed));
|
||||||
.inner
|
self.as_mut()
|
||||||
.set(DispatcherState::Upgrade(upgrade));
|
.project()
|
||||||
return self.poll(cx);
|
.inner
|
||||||
}
|
.set(DispatcherState::Upgrade(upgrade));
|
||||||
|
return self.poll(cx);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// we didn't get WouldBlock from write operation,
|
// we didn't get WouldBlock from write operation,
|
||||||
// so data get written to kernel completely (macOS)
|
// so data get written to kernel completely (macOS)
|
||||||
|
|
|
@ -175,7 +175,6 @@ pub fn main(_: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
let vis = &input.vis;
|
let vis = &input.vis;
|
||||||
let sig = &mut input.sig;
|
let sig = &mut input.sig;
|
||||||
let body = &input.block;
|
let body = &input.block;
|
||||||
let name = &sig.ident;
|
|
||||||
|
|
||||||
if sig.asyncness.is_none() {
|
if sig.asyncness.is_none() {
|
||||||
return syn::Error::new_spanned(sig.fn_token, "only async fn is supported")
|
return syn::Error::new_spanned(sig.fn_token, "only async fn is supported")
|
||||||
|
@ -188,7 +187,7 @@ pub fn main(_: TokenStream, item: TokenStream) -> TokenStream {
|
||||||
(quote! {
|
(quote! {
|
||||||
#(#attrs)*
|
#(#attrs)*
|
||||||
#vis #sig {
|
#vis #sig {
|
||||||
actix_web::rt::System::new(stringify!(#name))
|
actix_web::rt::System::new()
|
||||||
.block_on(async move { #body })
|
.block_on(async move { #body })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -40,7 +40,7 @@ compress = ["actix-http/compress"]
|
||||||
actix-codec = "0.4.0-beta.1"
|
actix-codec = "0.4.0-beta.1"
|
||||||
actix-service = "2.0.0-beta.3"
|
actix-service = "2.0.0-beta.3"
|
||||||
actix-http = "3.0.0-beta.1"
|
actix-http = "3.0.0-beta.1"
|
||||||
actix-rt = "2.0.0-beta.2"
|
actix-rt = "2.0.0-beta.3"
|
||||||
|
|
||||||
base64 = "0.13"
|
base64 = "0.13"
|
||||||
bytes = "1"
|
bytes = "1"
|
||||||
|
@ -58,9 +58,6 @@ open-ssl = { version = "0.10", package = "openssl", optional = true }
|
||||||
rust-tls = { version = "0.19.0", package = "rustls", optional = true, features = ["dangerous_configuration"] }
|
rust-tls = { version = "0.19.0", package = "rustls", optional = true, features = ["dangerous_configuration"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
# TODO: actix is temporary added as dev dep for actix-macro reason.
|
|
||||||
# Can be removed when it does not impact tests.
|
|
||||||
actix = "0.11.0-beta.1"
|
|
||||||
actix-web = { version = "4.0.0-beta.1", features = ["openssl"] }
|
actix-web = { version = "4.0.0-beta.1", features = ["openssl"] }
|
||||||
actix-http = { version = "3.0.0-beta.1", features = ["openssl"] }
|
actix-http = { version = "3.0.0-beta.1", features = ["openssl"] }
|
||||||
actix-http-test = { version = "3.0.0-beta.1", features = ["openssl"] }
|
actix-http-test = { version = "3.0.0-beta.1", features = ["openssl"] }
|
||||||
|
|
|
@ -21,7 +21,7 @@ use actix_rt::System;
|
||||||
use awc::Client;
|
use awc::Client;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
System::new("test").block_on(async {
|
System::new().block_on(async {
|
||||||
let client = Client::default();
|
let client = Client::default();
|
||||||
|
|
||||||
let res = client
|
let res = client
|
||||||
|
|
|
@ -68,7 +68,7 @@ impl<T: Responder> Responder for OptionResponder<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn future_responder(c: &mut Criterion) {
|
fn future_responder(c: &mut Criterion) {
|
||||||
let rt = actix_rt::System::new("test");
|
let rt = actix_rt::System::new();
|
||||||
let req = TestRequest::default().to_http_request();
|
let req = TestRequest::default().to_http_request();
|
||||||
|
|
||||||
c.bench_function("future_responder", move |b| {
|
c.bench_function("future_responder", move |b| {
|
||||||
|
@ -91,7 +91,7 @@ fn future_responder(c: &mut Criterion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn responder(c: &mut Criterion) {
|
fn responder(c: &mut Criterion) {
|
||||||
let rt = actix_rt::System::new("test");
|
let rt = actix_rt::System::new();
|
||||||
let req = TestRequest::default().to_http_request();
|
let req = TestRequest::default().to_http_request();
|
||||||
c.bench_function("responder", move |b| {
|
c.bench_function("responder", move |b| {
|
||||||
b.iter_custom(|_| {
|
b.iter_custom(|_| {
|
||||||
|
|
|
@ -29,7 +29,7 @@ const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||||
fn bench_async_burst(c: &mut Criterion) {
|
fn bench_async_burst(c: &mut Criterion) {
|
||||||
// We are using System here, since Runtime requires preinitialized tokio
|
// We are using System here, since Runtime requires preinitialized tokio
|
||||||
// Maybe add to actix_rt docs
|
// Maybe add to actix_rt docs
|
||||||
let rt = actix_rt::System::new("test");
|
let rt = actix_rt::System::new();
|
||||||
|
|
||||||
let srv = rt.block_on(async {
|
let srv = rt.block_on(async {
|
||||||
test::start(|| {
|
test::start(|| {
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub fn bench_async_service<S>(c: &mut Criterion, srv: S, name: &str)
|
||||||
where
|
where
|
||||||
S: Service<ServiceRequest, Response = ServiceResponse, Error = Error> + 'static,
|
S: Service<ServiceRequest, Response = ServiceResponse, Error = Error> + 'static,
|
||||||
{
|
{
|
||||||
let rt = actix_rt::System::new("test");
|
let rt = actix_rt::System::new();
|
||||||
let srv = Rc::new(RefCell::new(srv));
|
let srv = Rc::new(RefCell::new(srv));
|
||||||
|
|
||||||
let req = TestRequest::default().to_srv_request();
|
let req = TestRequest::default().to_srv_request();
|
||||||
|
@ -67,7 +67,7 @@ async fn index(req: ServiceRequest) -> Result<ServiceResponse, Error> {
|
||||||
// Sample results on MacBook Pro '14
|
// Sample results on MacBook Pro '14
|
||||||
// time: [2.0724 us 2.1345 us 2.2074 us]
|
// time: [2.0724 us 2.1345 us 2.2074 us]
|
||||||
fn async_web_service(c: &mut Criterion) {
|
fn async_web_service(c: &mut Criterion) {
|
||||||
let rt = actix_rt::System::new("test");
|
let rt = actix_rt::System::new();
|
||||||
let srv = Rc::new(RefCell::new(rt.block_on(init_service(
|
let srv = Rc::new(RefCell::new(rt.block_on(init_service(
|
||||||
App::new().service(web::service("/").finish(index)),
|
App::new().service(web::service("/").finish(index)),
|
||||||
))));
|
))));
|
||||||
|
|
|
@ -57,7 +57,7 @@ impl Default for TrailingSlash {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use actix_web::{web, middleware, App};
|
/// use actix_web::{web, middleware, App};
|
||||||
///
|
///
|
||||||
/// # actix_web::rt::System::new("doctest").block_on(async {
|
/// # actix_web::rt::System::new().block_on(async {
|
||||||
/// let app = App::new()
|
/// let app = App::new()
|
||||||
/// .wrap(middleware::NormalizePath::default())
|
/// .wrap(middleware::NormalizePath::default())
|
||||||
/// .route("/test", web::get().to(|| async { "test" }))
|
/// .route("/test", web::get().to(|| async { "test" }))
|
||||||
|
|
|
@ -667,7 +667,7 @@ where
|
||||||
|
|
||||||
// run server in separate thread
|
// run server in separate thread
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let sys = System::new("actix-test-server");
|
let sys = System::new();
|
||||||
let tcp = net::TcpListener::bind("127.0.0.1:0").unwrap();
|
let tcp = net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||||
let local_addr = tcp.local_addr().unwrap();
|
let local_addr = tcp.local_addr().unwrap();
|
||||||
let factory = factory.clone();
|
let factory = factory.clone();
|
||||||
|
|
|
@ -13,7 +13,7 @@ async fn test_start() {
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let sys = actix_rt::System::new("test");
|
let sys = actix_rt::System::new();
|
||||||
|
|
||||||
sys.block_on(async {
|
sys.block_on(async {
|
||||||
let srv = HttpServer::new(|| {
|
let srv = HttpServer::new(|| {
|
||||||
|
@ -91,7 +91,7 @@ async fn test_start_ssl() {
|
||||||
let (tx, rx) = mpsc::channel();
|
let (tx, rx) = mpsc::channel();
|
||||||
|
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let sys = actix_rt::System::new("test");
|
let sys = actix_rt::System::new();
|
||||||
let builder = ssl_acceptor().unwrap();
|
let builder = ssl_acceptor().unwrap();
|
||||||
|
|
||||||
let srv = HttpServer::new(|| {
|
let srv = HttpServer::new(|| {
|
||||||
|
|
Loading…
Reference in New Issue