1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-30 18:44:35 +01:00

Merge pull request #1399 from JohnTitor/new-http

Release actix-http 2.0.0-alpha.2
This commit is contained in:
Yuki Okushi 2020-03-08 01:47:40 +09:00 committed by GitHub
commit 5da9e277a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 52 additions and 32 deletions

View File

@ -71,7 +71,7 @@ actix-threadpool = "0.3.1"
actix-tls = "2.0.0-alpha.1" actix-tls = "2.0.0-alpha.1"
actix-web-codegen = "0.2.0" actix-web-codegen = "0.2.0"
actix-http = "2.0.0-alpha.1" actix-http = "2.0.0-alpha.2"
awc = { version = "1.0.1", default-features = false } awc = { version = "1.0.1", default-features = false }
bytes = "0.5.3" bytes = "0.5.3"

View File

@ -19,7 +19,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix-web = { version = "2.0.0-rc", default-features = false } actix-web = { version = "2.0.0-rc", default-features = false }
actix-http = "2.0.0-alpha.1" actix-http = "2.0.0-alpha.2"
actix-service = "1.0.1" actix-service = "1.0.1"
bitflags = "1" bitflags = "1"
bytes = "0.5.3" bytes = "0.5.3"

View File

@ -23,7 +23,7 @@ actix-codec = "0.2.0"
actix-service = "1.0.1" actix-service = "1.0.1"
actix-router = "0.2.1" actix-router = "0.2.1"
actix-rt = "1.0.0" actix-rt = "1.0.0"
actix-http = "2.0.0-alpha.1" actix-http = "2.0.0-alpha.2"
bytes = "0.5.3" bytes = "0.5.3"
futures = "0.3.1" futures = "0.3.1"

View File

@ -1,16 +1,20 @@
# Changes # Changes
## [2.0.0-alpha.2] - someday ## [2.0.0-alpha.2] - 2020-03-07
### Changed ### Changed
* Update `actix-connect` and `actix-tls` dependency to 2.0.0-alpha.1 * Update `actix-connect` and `actix-tls` dependency to 2.0.0-alpha.1. [#1395]
* Change default initial window size and connection window size for HTTP2 to 2MB and 1MB respectively to improve download speed for awc when downloading large objects. * Change default initial window size and connection window size for HTTP2 to 2MB and 1MB respectively
to improve download speed for awc when downloading large objects. [#1394]
* client::Connector accepts initial_window_size and initial_connection_window_size HTTP2 configuration * client::Connector accepts initial_window_size and initial_connection_window_size HTTP2 configuration. [#1394]
* client::Connector allowing to set max_http_version to limit HTTP version to be used * client::Connector allowing to set max_http_version to limit HTTP version to be used. [#1394]
[#1394]: https://github.com/actix/actix-web/pull/1394
[#1395]: https://github.com/actix/actix-web/pull/1395
## [2.0.0-alpha.1] - 2020-02-27 ## [2.0.0-alpha.1] - 2020-02-27

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-http" name = "actix-http"
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 http primitives" description = "Actix http primitives"
readme = "README.md" readme = "README.md"

View File

@ -14,19 +14,34 @@ Actix http
```rust ```rust
// see examples/framed_hello.rs for complete list of used crates. // see examples/framed_hello.rs for complete list of used crates.
extern crate actix_http; use std::{env, io};
use actix_http::{h1, Response, ServiceConfig};
fn main() { use actix_http::{HttpService, Response};
Server::new().bind("framed_hello", "127.0.0.1:8080", || { use actix_server::Server;
IntoFramed::new(|| h1::Codec::new(ServiceConfig::default())) // <- create h1 codec use futures::future;
.and_then(TakeItem::new().map_err(|_| ())) // <- read one request use http::header::HeaderValue;
.and_then(|(_req, _framed): (_, Framed<_, _>)| { // <- send response and close conn use log::info;
SendResponse::send(_framed, Response::Ok().body("Hello world!"))
.map_err(|_| ()) #[actix_rt::main]
.map(|_| ()) async fn main() -> io::Result<()> {
env::set_var("RUST_LOG", "hello_world=info");
env_logger::init();
Server::build()
.bind("hello-world", "127.0.0.1:8080", || {
HttpService::build()
.client_timeout(1000)
.client_disconnect(1000)
.finish(|_req| {
info!("{:?}", _req);
let mut res = Response::Ok();
res.header("x-head", HeaderValue::from_static("dummy value!"));
future::ok::<_, ()>(res.body("Hello world!"))
}) })
}).unwrap().run(); .tcp()
})?
.run()
.await
} }
``` ```

View File

@ -78,8 +78,7 @@ impl Connector<(), ()> {
// Build Ssl connector with openssl, based on supplied alpn protocols // Build Ssl connector with openssl, based on supplied alpn protocols
#[cfg(feature = "openssl")] #[cfg(feature = "openssl")]
fn build_ssl(protocols: Vec<Vec<u8>>) -> SslConnector fn build_ssl(protocols: Vec<Vec<u8>>) -> SslConnector {
{
use actix_connect::ssl::openssl::SslMethod; use actix_connect::ssl::openssl::SslMethod;
use bytes::{BufMut, BytesMut}; use bytes::{BufMut, BytesMut};
@ -98,8 +97,7 @@ impl Connector<(), ()> {
// Build Ssl connector with rustls, based on supplied alpn protocols // Build Ssl connector with rustls, based on supplied alpn protocols
#[cfg(all(not(feature = "openssl"), feature = "rustls"))] #[cfg(all(not(feature = "openssl"), feature = "rustls"))]
fn build_ssl(protocols: Vec<Vec<u8>>) -> SslConnector fn build_ssl(protocols: Vec<Vec<u8>>) -> SslConnector {
{
let mut config = ClientConfig::new(); let mut config = ClientConfig::new();
config.set_protocols(&protocols); config.set_protocols(&protocols);
config config
@ -169,7 +167,9 @@ where
let versions = match val { let versions = match val {
http::Version::HTTP_11 => vec![b"http/1.1".to_vec()], http::Version::HTTP_11 => vec![b"http/1.1".to_vec()],
http::Version::HTTP_2 => vec![b"h2".to_vec(), b"http/1.1".to_vec()], http::Version::HTTP_2 => vec![b"h2".to_vec(), b"http/1.1".to_vec()],
_ => unimplemented!("actix-http:client: supported versions http/1.1, http/2"), _ => {
unimplemented!("actix-http:client: supported versions http/1.1, http/2")
}
}; };
self.ssl = Connector::build_ssl(versions); self.ssl = Connector::build_ssl(versions);
self self

View File

@ -395,7 +395,8 @@ where
Poll::Ready(Ok(req)) => { Poll::Ready(Ok(req)) => {
self.as_mut().send_continue(); self.as_mut().send_continue();
this = self.as_mut().project(); this = self.as_mut().project();
this.state.set(State::ServiceCall(Box::pin(this.service.call(req)))); this.state
.set(State::ServiceCall(Box::pin(this.service.call(req))));
continue; continue;
} }
Poll::Ready(Err(e)) => { Poll::Ready(Err(e)) => {

View File

@ -29,4 +29,4 @@ twoway = "0.2"
[dev-dependencies] [dev-dependencies]
actix-rt = "1.0.0" actix-rt = "1.0.0"
actix-http = "2.0.0-alpha.1" actix-http = "2.0.0-alpha.2"

View File

@ -18,7 +18,7 @@ path = "src/lib.rs"
[dependencies] [dependencies]
actix = "0.10.0-alpha.1" actix = "0.10.0-alpha.1"
actix-web = "2.0.0" actix-web = "2.0.0"
actix-http = "2.0.0-alpha.1" actix-http = "2.0.0-alpha.2"
actix-codec = "0.2.0" actix-codec = "0.2.0"
bytes = "0.5.2" bytes = "0.5.2"
futures = "0.3.1" futures = "0.3.1"

View File

@ -36,7 +36,7 @@ compress = ["actix-http/compress"]
[dependencies] [dependencies]
actix-codec = "0.2.0" actix-codec = "0.2.0"
actix-service = "1.0.1" actix-service = "1.0.1"
actix-http = "2.0.0-alpha.1" actix-http = "2.0.0-alpha.2"
actix-rt = "1.0.0" actix-rt = "1.0.0"
base64 = "0.11" base64 = "0.11"
@ -56,7 +56,7 @@ rust-tls = { version = "0.17.0", package="rustls", optional = true, features = [
[dev-dependencies] [dev-dependencies]
actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] } actix-connect = { version = "2.0.0-alpha.1", features=["openssl"] }
actix-web = { version = "2.0.0", features=["openssl"] } actix-web = { version = "2.0.0", features=["openssl"] }
actix-http = { version = "2.0.0-alpha.1", features=["openssl"] } actix-http = { version = "2.0.0-alpha.2", 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"
actix-server = "1.0.0" actix-server = "1.0.0"

View File

@ -56,4 +56,4 @@ open-ssl = { version="0.10", package="openssl", optional = true }
[dev-dependencies] [dev-dependencies]
actix-web = "2.0.0" actix-web = "2.0.0"
actix-http = "2.0.0-alpha.1" actix-http = "2.0.0-alpha.2"