Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rebase local patches on top of v0.14.27 #4

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
031425f
feat(http2): add `http2_max_header_list_size` to `hyper::server::Buil…
jiahaoliang Dec 20, 2022
4d89adc
fix(body): set an internal max to reserve in `to_bytes`
seanmonstar Jan 11, 2023
92443d7
fix(server): prevent sending 100-continue if user drops request body …
seanmonstar Feb 2, 2023
40c01df
v0.14.24
seanmonstar Feb 2, 2023
37ed5a2
feat(client): add `poison` to `Connected` (#3145)
rcoh Feb 20, 2023
c849339
feat(client): add `client::connect::capture_connection()` (#3144)
rcoh Feb 22, 2023
253cc74
feat(client): add 1.0 compatible client conn API (#3155)
seanmonstar Mar 6, 2023
0ced15d
feat(client): deprecate `client::conn` types (#3156)
seanmonstar Mar 7, 2023
0368a41
feat(server): remove some `Unpin` and `'static` constraints (#3119)
taikulawo Mar 7, 2023
84881c9
feat(server): backport the split server conn modules from 1.0 (#3102)
oddgrd Mar 8, 2023
02fe20f
feat(server): deprecate server conn structs (#3161)
oddgrd Mar 9, 2023
86bc750
refactor(server): allow deprecated in the server module (#3165)
oddgrd Mar 9, 2023
fc111eb
chore(ci): test deprecations in CI (#3162)
seanmonstar Mar 9, 2023
645db19
docs(lib): document backport and deprecated features (#3166)
seanmonstar Mar 10, 2023
a9d4e83
v0.14.25
seanmonstar Mar 10, 2023
a6f7571
feat(http2): add `max_pending_accept_reset_streams` configuration opt…
Noah-Kennedy Apr 13, 2023
00d52e4
v0.14.26
seanmonstar Apr 13, 2023
297dc4c
feat(client): include connection info in Client::send_request errors…
nox Apr 14, 2023
32422c4
fix(http1): properly end chunked bodies when it was known to be empty…
seanmonstar Jun 19, 2023
b107655
fix(http1): send error on Incoming body when connection errors (#3256)
seanmonstar Jun 19, 2023
a7b2c82
chore(lib): disable log feature of tower dependency
seanmonstar Jun 19, 2023
d77c259
v0.14.27
seanmonstar Jun 26, 2023
7c2c3b1
Allow special headers w/ arbitrary name casing (#1)
svix-james Dec 1, 2022
e6011ae
Make HeaderCaseMap public (#2)
svix-james Dec 9, 2022
e12310c
Add `get` method to `HeaderCaseMap` (#3)
svix-james Dec 14, 2022
19c6acd
XXX: not sure why but tests fail because of these lints
svix-onelson Nov 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- msrv
- miri
- features
- deprecated
- ffi
- ffi-header
- doc
Expand Down Expand Up @@ -62,11 +63,11 @@ jobs:

include:
- rust: stable
features: "--features full"
features: "--features full,backports,deprecated"
- rust: beta
features: "--features full"
features: "--features full,backports"
- rust: nightly
features: "--features full,nightly"
features: "--features full,nightly,backports"
benches: true

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -167,6 +168,34 @@ jobs:
- name: check --feature-powerset
run: cargo hack check --feature-powerset --depth 2 --skip ffi -Z avoid-dev-deps

deprecated:
name: Check deprecated on ${{ matrix.rust }}
needs: [style]
strategy:
matrix:
rust:
- stable
- beta

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install Rust (${{ matrix.rust }})
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true

- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --features full,backports,deprecated

ffi:
name: Test C API (FFI)
needs: [style]
Expand Down
53 changes: 53 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
### v0.14.27 (2023-06-26)


#### Bug Fixes

* **http1:**
* send error on Incoming body when connection errors (#3256) ([b107655f](https://github.com/hyperium/hyper/commit/b107655ff8557d001bb8e558752f5f2247381e98), closes [#3253](https://github.com/hyperium/hyper/issues/3253))
* properly end chunked bodies when it was known to be empty (#3254) ([32422c47](https://github.com/hyperium/hyper/commit/32422c47ec35e7405873277c87de14c18dbb98bd), closes [#3252](https://github.com/hyperium/hyper/issues/3252))


#### Features

* **client:** include connection info in `Client::send_request` errors (#2749)


### v0.14.26 (2023-04-13)


#### Features

* **http2:** add `max_pending_accept_reset_streams` configuration option (#3201) ([a6f7571a](https://github.com/hyperium/hyper/commit/a6f7571a5299793aef8f1aa4194574438b9df64c))


### v0.14.25 (2023-03-10)


#### Features

* **client:**
* deprecate `client::conn` types (#3156) ([0ced15d3](https://github.com/hyperium/hyper/commit/0ced15d3cc10ace477ebda13ead8e6857b51867e))
* add 1.0 compatible client conn API (#3155) ([253cc74d](https://github.com/hyperium/hyper/commit/253cc74d86b082067aa884a0a63a089d7d19401d), closes [#3053](https://github.com/hyperium/hyper/issues/3053))
* add `client::connect::capture_connection()` (#3144) ([c8493399](https://github.com/hyperium/hyper/commit/c8493399b2929a86f3020ae77304a00e43cfd161))
* add `poison` to `Connected` (#3145) ([37ed5a2e](https://github.com/hyperium/hyper/commit/37ed5a2e3cab76a11092823a80afd8fe2f2a9693))
* **server:**
* deprecate server conn structs (#3161) ([02fe20f2](https://github.com/hyperium/hyper/commit/02fe20f232a7c3cf24d505b121ce4d428a93254d))
* backport the split server conn modules from 1.0 (#3102) ([84881c9e](https://github.com/hyperium/hyper/commit/84881c9e5160167a89d18d30c0ef6856dc859839), closes [#3079](https://github.com/hyperium/hyper/issues/3079))
* remove some `Unpin` and `'static` constraints (#3119) ([0368a41a](https://github.com/hyperium/hyper/commit/0368a41a6cc1a5c6f1eada0d88e38b7dce261587))


### v0.14.24 (2023-02-02)


#### Bug Fixes

* **body:** set an internal max to reserve in `to_bytes` ([4d89adce](https://github.com/hyperium/hyper/commit/4d89adce6122af1650165337d9d814314e7ee409))
* **server:** prevent sending 100-continue if user drops request body (#3138) ([92443d7e](https://github.com/hyperium/hyper/commit/92443d7ef57ed474f0add7dd1f114c81a3faa8fe))


#### Features

* **http2:** add `http2_max_header_list_size` to `hyper::server::Builder` (#3006) ([031425f0](https://github.com/hyperium/hyper/commit/031425f087219f02a87eea3d01b14e75e35a5209))


### v0.14.23 (2022-11-07)


Expand Down
12 changes: 9 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hyper"
version = "0.14.23"
version = "0.14.27"
description = "A fast and correct HTTP library."
readme = "README.md"
homepage = "https://hyper.rs"
Expand Down Expand Up @@ -28,7 +28,7 @@ http = "0.2"
http-body = "0.4"
httpdate = "1.0"
httparse = "1.8"
h2 = { version = "0.3.9", optional = true }
h2 = { version = "0.3.17", optional = true }
itoa = "1"
tracing = { version = "0.1", default-features = false, features = ["std"] }
pin-project-lite = "0.2.4"
Expand Down Expand Up @@ -62,7 +62,7 @@ tokio = { version = "1", features = [
] }
tokio-test = "0.4"
tokio-util = { version = "0.7", features = ["codec"] }
tower = { version = "0.4", features = ["make", "util"] }
tower = { version = "0.4", default-features = false, features = ["make", "util"] }
url = "2.2"

[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies]
Expand Down Expand Up @@ -109,6 +109,12 @@ tcp = [
# C-API support (currently unstable (no semver))
ffi = ["libc"]

# enable 1.0 backports
backports = []

# whether or not to display deprecation warnings
deprecated = []

# internal features used in CI
nightly = []
__internal_happy_eyeballs_tests = []
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ libraries and applications.

If you are looking for a convenient HTTP client, then you may wish to consider
[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).
convenient HTTP server, then you may wish to consider [Axum](https://github.com/tokio-rs/tokio).
Both are built on top of this library.

## Contributing
Expand Down
48 changes: 40 additions & 8 deletions examples/tower_client.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#![deny(warnings)]

use hyper::client::conn::Builder;
use hyper::client::connect::HttpConnector;
use hyper::client::service::Connect;
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};

use hyper::service::Service;
use hyper::{Body, Request};
use hyper::{Body, Request, Response};
use tokio::net::TcpStream;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>> {
pretty_env_logger::init();

let mut mk_svc = Connect::new(HttpConnector::new(), Builder::new());

let uri = "http://127.0.0.1:8080".parse::<http::Uri>()?;

let mut svc = mk_svc.call(uri.clone()).await?;
let mut svc = Connector;

let body = Body::empty();

Expand All @@ -25,3 +25,35 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

Ok(())
}

struct Connector;

impl Service<Request<Body>> for Connector {
type Response = Response<Body>;
type Error = Box<dyn std::error::Error + Send + Sync + 'static>;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;

fn poll_ready(&mut self, _cx: &mut Context<'_>) -> std::task::Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}

fn call(&mut self, req: Request<Body>) -> Self::Future {
Box::pin(async move {
let host = req.uri().host().expect("no host in uri");
let port = req.uri().port_u16().expect("no port in uri");

let stream = TcpStream::connect(format!("{}:{}", host, port)).await?;

let (mut sender, conn) = hyper::client::conn::http1::handshake(stream).await?;

tokio::task::spawn(async move {
if let Err(err) = conn.await {
println!("Connection error: {:?}", err);
}
});

let res = sender.send_request(req).await?;
Ok(res)
})
}
}
17 changes: 8 additions & 9 deletions src/body/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ type TrailersSender = oneshot::Sender<HeaderMap>;
/// A good default [`HttpBody`](crate::body::HttpBody) to use in many
/// applications.
///
/// Note: To read the full body, use [`body::to_bytes`](crate::body::to_bytes)
/// or [`body::aggregate`](crate::body::aggregate).
/// Note: To read the full body, use [`body::to_bytes`](crate::body::to_bytes())
/// or [`body::aggregate`](crate::body::aggregate()).
#[must_use = "streams do nothing unless polled"]
pub struct Body {
kind: Kind,
Expand Down Expand Up @@ -602,17 +602,16 @@ impl Sender {
}

/// Aborts the body in an abnormal fashion.
pub fn abort(self) {
pub fn abort(mut self) {
self.send_error(crate::Error::new_body_write_aborted());
}

pub(crate) fn send_error(&mut self, err: crate::Error) {
let _ = self
.data_tx
// clone so the send works even if buffer is full
.clone()
.try_send(Err(crate::Error::new_body_write_aborted()));
}

#[cfg(feature = "http1")]
pub(crate) fn send_error(&mut self, err: crate::Error) {
let _ = self.data_tx.try_send(Err(err));
.try_send(Err(err));
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/body/to_bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,13 @@ where
return Ok(first.copy_to_bytes(first.remaining()));
};

// Don't pre-emptively reserve *too* much.
let rest = (body.size_hint().lower() as usize).min(1024 * 16);
let cap = first
.remaining()
.saturating_add(second.remaining())
.saturating_add(rest);
// With more than 1 buf, we gotta flatten into a Vec first.
let cap = first.remaining() + second.remaining() + body.size_hint().lower() as usize;
let mut vec = Vec::with_capacity(cap);
vec.put(first);
vec.put(second);
Expand Down
Loading
Loading