Skip to content

Commit

Permalink
Merge branch 'master' into service-for-client-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar authored Jun 24, 2020
2 parents aa873dd + 07f2fd1 commit 8c223f4
Show file tree
Hide file tree
Showing 66 changed files with 3,278 additions and 1,077 deletions.
15 changes: 2 additions & 13 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- stable
- beta
- nightly
# - 1.39.0
- 1.39.0

os:
- ubuntu-latest
Expand All @@ -58,9 +58,6 @@ jobs:
- rust: stable
os: ubuntu-latest
features: "--features __internal_happy_eyeballs_tests"
# - rust: 1.39.0
# features: "--no-default-features --features runtime"
# build-only: true

runs-on: ${{ matrix.os }}

Expand All @@ -75,22 +72,14 @@ jobs:
toolchain: ${{ matrix.rust }}
override: true

- name: Build only
if: matrix.build-only
uses: actions-rs/cargo@v1
with:
command: build
args: ${{ matrix.features }}

- name: Test
if: matrix.build-only != true
uses: actions-rs/cargo@v1
with:
command: test
args: ${{ matrix.features }}

- name: Test all benches
if: matrix.benches && matrix.build-only != true
if: matrix.benches
uses: actions-rs/cargo@v1
with:
command: test
Expand Down
32 changes: 0 additions & 32 deletions .travis/docs.sh

This file was deleted.

10 changes: 0 additions & 10 deletions .travis/readme.py

This file was deleted.

58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
### v0.13.6 (2020-05-29)


#### Features

* **body:** remove Sync bound for Body::wrap_stream ([042c7706](https://github.com/hyperium/hyper/commit/042c770603a212f22387807efe4fc672959df40c))
* **http2:** allow configuring the HTTP/2 frame size ([b6446456](https://github.com/hyperium/hyper/commit/b64464562a02a642a3cf16ea072f39621da21980))


### v0.13.5 (2020-04-17)


#### Bug Fixes

* **server:** fix panic in Connection::graceful_shutdown ([fce3ddce](https://github.com/hyperium/hyper/commit/fce3ddce4671e7df439a9d8fdc469b079fc07318))


### v0.13.4 (2020-03-20)


#### Bug Fixes

* **http1:** try to drain connection buffer if user drops Body ([d838d54f](https://github.com/hyperium/hyper/commit/d838d54fdf0fc4a613612f68274f3520f333dd8e))


#### Features

* **http2:** add HTTP2 keep-alive support for client and server ([9a8413d9](https://github.com/hyperium/hyper/commit/9a8413d91081ad5a949276f05337e984c455e251))


### v0.13.3 (2020-03-03)


#### Features

* **client:** rename `client::Builder` pool options (#2142) ([a82fd6c9](https://github.com/hyperium/hyper/commit/a82fd6c94aa4ce11fe685f9ccfb85c596d596c6e))
* **http2:** add adaptive window size support using BDP (#2138) ([48102d61](https://github.com/hyperium/hyper/commit/48102d61228b592b466af273a81207e729315681))
* **server:** add `poll_peek` to `AddrStream` (#2127) ([24d53d3f](https://github.com/hyperium/hyper/commit/24d53d3f66f843a6c19204cc7c52cd80e327d41a))


### v0.13.2 (2020-01-29)


#### Bug Fixes

* **body:** return exactly 0 SizeHint for empty body (#2122) ([dc882047](https://github.com/hyperium/hyper/commit/dc88204716664d12e20598c78cb87cd44c6f23af))
* **client:** strip path from Uri before calling Connector (#2109) ([ba2a144f](https://github.com/hyperium/hyper/commit/ba2a144f8b81042247088215425f91760d8694a1))
* **http1:**
* only send `100 Continue` if request body is polled ([c4bb4db5](https://github.com/hyperium/hyper/commit/c4bb4db5c219459b37d796f9aa2b3cdc93325621))
* remove panic for HTTP upgrades that have been ignored (#2115) ([1881db63](https://github.com/hyperium/hyper/commit/1881db6391acc949384f8ddfcac8c82a2b133c8d), closes [#2114](https://github.com/hyperium/hyper/issues/2114))
* **http2:** don't add client content-length if method doesn't require it ([fb90d30c](https://github.com/hyperium/hyper/commit/fb90d30c02d8f7cdc9a643597d5c4ca7a123f3dd))


#### Features

* **service:** Implement Clone/Copy on ServiceFn and MakeServiceFn (#2104) ([a5720fab](https://github.com/hyperium/hyper/commit/a5720fab4ced447b8ade43cc1ce8b35442ebf234))


### v0.13.1 (2019-12-13)


Expand Down
26 changes: 14 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hyper"
version = "0.13.1" # don't forget to update html_root_url
version = "0.13.6" # don't forget to update html_root_url
description = "A fast and correct HTTP library."
readme = "README.md"
homepage = "https://hyper.rs"
Expand All @@ -27,30 +27,32 @@ futures-util = { version = "0.3", default-features = false }
http = "0.2"
http-body = "0.3.1"
httparse = "1.0"
h2 = "0.2.1"
h2 = "0.2.2"
itoa = "0.4.1"
log = "0.4"
pin-project = "0.4"
pin-project = "0.4.20"
time = "0.1"
tower-service = "0.3"
tokio = { version = "0.2", features = ["sync"] }
tokio = { version = "0.2.5", features = ["sync"] }
want = "0.3"

# Optional

net2 = { version = "0.2.32", optional = true }
socket2 = { version = "0.3", optional = true }

[dev-dependencies]
futures-util = { version = "0.3", default-features = false, features = ["alloc"] }
matches = "0.1"
num_cpus = "1.0"
pretty_env_logger = "0.3"
pretty_env_logger = "0.4"
spmc = "0.3"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tokio = { version = "0.2.2", features = ["fs", "macros", "io-std", "rt-util", "sync", "time", "test-util"] }
tokio-test = "0.2"
tokio-util = { version = "0.3", features = ["codec"] }
tower-util = "0.3"
url = "1.0"

[features]
Expand All @@ -63,7 +65,7 @@ runtime = [
"tokio/rt-core",
]
tcp = [
"net2",
"socket2",
"tokio/blocking",
"tokio/tcp",
"tokio/time",
Expand Down Expand Up @@ -105,6 +107,11 @@ name = "echo"
path = "examples/echo.rs"
required-features = ["runtime", "stream"]

[[example]]
name = "gateway"
path = "examples/gateway.rs"
required-features = ["runtime"]

[[example]]
name = "hello"
path = "examples/hello.rs"
Expand All @@ -125,11 +132,6 @@ name = "params"
path = "examples/params.rs"
required-features = ["runtime", "stream"]

[[example]]
name = "proxy"
path = "examples/proxy.rs"
required-features = ["runtime"]

[[example]]
name = "send_file"
path = "examples/send_file.rs"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ hyper is a relatively low-level library, meant to be a building block for
libraries and applications.

If you are looking for a convenient HTTP client, then you may wish to consider
[reqwest](https://github.com/seanmonstar/reqwest), which is built on top of
this library.
[reqwest](https://github.com/seanmonstar/reqwest). If you are looking for a
convenient HTTP server, then you may wish to consider [warp](https://github.com/seanmonstar/warp).
Both are built on top of this library.

## Contributing

Expand Down
47 changes: 34 additions & 13 deletions benches/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ fn http2_parallel_x10_req_10kb_100_chunks(b: &mut test::Bencher) {
.bench(b)
}

#[bench]
fn http2_parallel_x10_req_10kb_100_chunks_adaptive_window(b: &mut test::Bencher) {
let body = &[b'x'; 1024 * 10];
opts()
.http2()
.parallel(10)
.method(Method::POST)
.request_chunks(body, 100)
.http2_adaptive_window()
.bench(b)
}

#[bench]
fn http2_parallel_x10_req_10kb_100_chunks_max_window(b: &mut test::Bencher) {
let body = &[b'x'; 1024 * 10];
Expand Down Expand Up @@ -182,6 +194,7 @@ struct Opts {
http2: bool,
http2_stream_window: Option<u32>,
http2_conn_window: Option<u32>,
http2_adaptive_window: bool,
parallel_cnt: u32,
request_method: Method,
request_body: Option<&'static [u8]>,
Expand All @@ -194,11 +207,12 @@ fn opts() -> Opts {
http2: false,
http2_stream_window: None,
http2_conn_window: None,
http2_adaptive_window: false,
parallel_cnt: 1,
request_method: Method::GET,
request_body: None,
request_chunks: 0,
response_body: b"Hello",
response_body: b"",
}
}

Expand All @@ -209,15 +223,24 @@ impl Opts {
}

fn http2_stream_window(mut self, sz: impl Into<Option<u32>>) -> Self {
assert!(!self.http2_adaptive_window);
self.http2_stream_window = sz.into();
self
}

fn http2_conn_window(mut self, sz: impl Into<Option<u32>>) -> Self {
assert!(!self.http2_adaptive_window);
self.http2_conn_window = sz.into();
self
}

fn http2_adaptive_window(mut self) -> Self {
assert!(self.http2_stream_window.is_none());
assert!(self.http2_conn_window.is_none());
self.http2_adaptive_window = true;
self
}

fn method(mut self, m: Method) -> Self {
self.request_method = m;
self
Expand Down Expand Up @@ -272,6 +295,7 @@ impl Opts {
.http2_only(self.http2)
.http2_initial_stream_window_size(self.http2_stream_window)
.http2_initial_connection_window_size(self.http2_conn_window)
.http2_adaptive_window(self.http2_adaptive_window)
.build::<_, Body>(connector);

let url: hyper::Uri = format!("http://{}/hello", addr).parse().unwrap();
Expand All @@ -292,7 +316,7 @@ impl Opts {
} else {
self.request_body
.map(Body::from)
.unwrap_or_else(|| Body::empty())
.unwrap_or_else(Body::empty)
};
let mut req = Request::new(body);
*req.method_mut() = self.request_method.clone();
Expand Down Expand Up @@ -337,16 +361,13 @@ fn spawn_server(rt: &mut tokio::runtime::Runtime, opts: &Opts) -> SocketAddr {
.http2_only(opts.http2)
.http2_initial_stream_window_size(opts.http2_stream_window)
.http2_initial_connection_window_size(opts.http2_conn_window)
.serve(make_service_fn(move |_| {
async move {
Ok::<_, hyper::Error>(service_fn(move |req: Request<Body>| {
async move {
let mut req_body = req.into_body();
while let Some(_chunk) = req_body.data().await {}
Ok::<_, hyper::Error>(Response::new(Body::from(body)))
}
}))
}
.http2_adaptive_window(opts.http2_adaptive_window)
.serve(make_service_fn(move |_| async move {
Ok::<_, hyper::Error>(service_fn(move |req: Request<Body>| async move {
let mut req_body = req.into_body();
while let Some(_chunk) = req_body.data().await {}
Ok::<_, hyper::Error>(Response::new(Body::from(body)))
}))
}))
});
let addr = srv.local_addr();
Expand All @@ -355,5 +376,5 @@ fn spawn_server(rt: &mut tokio::runtime::Runtime, opts: &Opts) -> SocketAddr {
panic!("server error: {}", err);
}
});
return addr;
addr
}
10 changes: 4 additions & 6 deletions benches/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ fn hello_world(b: &mut test::Bencher) {
std::thread::spawn(move || {
let addr = "127.0.0.1:0".parse().unwrap();

let make_svc = make_service_fn(|_| {
async {
Ok::<_, hyper::Error>(service_fn(|_| {
async { Ok::<_, hyper::Error>(Response::new(Body::from("Hello, World!"))) }
}))
}
let make_svc = make_service_fn(|_| async {
Ok::<_, hyper::Error>(service_fn(|_| async {
Ok::<_, hyper::Error>(Response::new(Body::from("Hello, World!")))
}))
});

let mut rt = tokio::runtime::Builder::new()
Expand Down
Loading

0 comments on commit 8c223f4

Please sign in to comment.