Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 64eaf51

Browse files
0x676e674JXseanmonstardswijNoah-Kennedy
authoredAug 11, 2024
Merge patch (hyperium#4)
* Add a setter for header_table_size * Include a test for setting header_table_size * Fix formatting * Switch pseudo header order to mimic chrome * support chrome/okhttp impersonate * deps(http): bump version to v0.2.11 * feat(header): support safari header pseudo order * Send frames based on custom configuration * Revert "deps(http): bump version to v0.2.11" * deps(http): bump version to v0.2.11 * bump version to v0.4.2 * fix: streams awaiting capacity lockout (hyperium#730) (hyperium#734) This PR changes the the assign-capacity queue to prioritize streams that are send-ready. This is necessary to prevent a lockout when streams aren't able to proceed while waiting for connection capacity, but there is none. Closes hyperium/hyper#3338 Co-authored-by: dswij <dharmasw@outlook.com> * streams: limit error resets for misbehaving connections This change causes GOAWAYs to be issued to misbehaving connections which for one reason or another cause us to emit lots of error resets. Error resets are not generally expected from valid implementations anyways. The threshold after which we issue GOAWAYs is tunable, and will default to 1024. * Prepare v0.3.24 * perf: optimize header list size calculations (hyperium#750) This speeds up loading blocks in cases where we have many headers already. * deps(http): v0.2 * Fix header order * Optimize pseudo-header sort * Setting static headers * feat(frame): Passing values ​​to solve pseudo order * Add headers priority * Fix default flag * Project rename to `h2-patch` --------- Co-authored-by: 4JX <79868816+4JX@users.noreply.github.com> Co-authored-by: Sean McArthur <sean@seanmonstar.com> Co-authored-by: dswij <dharmasw@outlook.com> Co-authored-by: Noah Kennedy <nkennedy@cloudflare.com>
1 parent 36cf4f2 commit 64eaf51

31 files changed

+342
-210
lines changed
 

‎.github/workflows/CI.yml

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
strategy:
3232
matrix:
3333
rust:
34-
- nightly
3534
- beta
3635
- stable
3736
steps:

‎CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
* Update to `http` 1.0.
2828
* Remove deprecated `Server::poll_close()`.
2929

30+
# 0.3.24 (January 17, 2024)
31+
32+
* Limit error resets for misbehaving connections.
33+
34+
# 0.3.23 (January 10, 2024)
35+
36+
* Backport fix from 0.4.1 for stream capacity assignment.
37+
3038
# 0.3.22 (November 15, 2023)
3139

3240
* Add `header_table_size(usize)` option to client and server builders.

‎Cargo.toml

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[package]
2-
name = "h2"
2+
name = "h2-patch"
33
# When releasing to crates.io:
44
# - Update CHANGELOG.md.
55
# - Create git tag
6-
version = "0.4.5"
6+
version = "0.5.7"
77
license = "MIT"
88
authors = [
99
"Carl Lerche <me@carllerche.com>",
@@ -45,8 +45,8 @@ futures-sink = { version = "0.3", default-features = false }
4545
tokio-util = { version = "0.7.1", features = ["codec", "io"] }
4646
tokio = { version = "1", features = ["io-util"] }
4747
bytes = "1"
48-
http = "1"
49-
tracing = { version = "0.1.35", default-features = false, features = ["std"] }
48+
http = "0.2"
49+
tracing = { version = "0.1.32", default-features = false, features = ["std"] }
5050
fnv = "1.0.5"
5151
slab = "0.4.2"
5252
indexmap = { version = "2", features = ["std"] }
@@ -66,6 +66,7 @@ serde_json = "1.0.0"
6666
# Examples
6767
tokio = { version = "1", features = ["rt-multi-thread", "macros", "sync", "net"] }
6868
env_logger = { version = "0.10", default-features = false }
69+
6970
tokio-rustls = "0.26"
7071
webpki-roots = "0.26"
7172

‎benches/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use h2_patch as h2;
12
use bytes::Bytes;
23
use h2::{
34
client,

‎examples/akamai.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use h2::client;
2+
use h2_patch as h2;
23
use http::{Method, Request};
34
use tokio::net::TcpStream;
45
use tokio_rustls::TlsConnector;

‎examples/client.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use h2::client;
2+
use h2_patch as h2;
23
use http::{HeaderMap, Request};
34

45
use std::error::Error;

‎examples/server.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use h2_patch as h2;
12
use std::error::Error;
23

34
use bytes::Bytes;

‎fuzz/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ tokio = { version = "1", features = [ "full" ] }
1616
h2 = { path = "../", features = [ "unstable" ] }
1717
h2-support = { path = "../tests/h2-support" }
1818
futures = { version = "0.3", default-features = false, features = ["std"] }
19-
http = "1"
19+
http = "0.2"
2020

2121
# Prevent this from interfering with workspaces
2222
[workspace]

‎src/client.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
use crate::codec::{Codec, SendError, UserError};
139139
use crate::ext::Protocol;
140140
use crate::frame::{Headers, Pseudo, Reason, Settings, StreamId};
141+
use crate::profile::AgentProfile;
141142
use crate::proto::{self, Error};
142143
use crate::{FlowControl, PingPong, RecvStream, SendStream};
143144

@@ -175,6 +176,7 @@ use tracing::Instrument;
175176
pub struct SendRequest<B: Buf> {
176177
inner: proto::Streams<B, Peer>,
177178
pending: Option<proto::OpaqueStreamRef>,
179+
profile: AgentProfile,
178180
}
179181

180182
/// Returns a `SendRequest` instance once it is ready to send at least one
@@ -343,6 +345,9 @@ pub struct Builder {
343345
///
344346
/// When this gets exceeded, we issue GOAWAYs.
345347
local_max_error_reset_streams: Option<usize>,
348+
349+
/// Profile Settings
350+
_profile: AgentProfile,
346351
}
347352

348353
#[derive(Debug)]
@@ -515,7 +520,12 @@ where
515520
end_of_stream: bool,
516521
) -> Result<(ResponseFuture, SendStream<B>), crate::Error> {
517522
self.inner
518-
.send_request(request, end_of_stream, self.pending.as_ref())
523+
.send_request(
524+
request,
525+
end_of_stream,
526+
self.pending.as_ref(),
527+
self.profile.clone(),
528+
)
519529
.map_err(Into::into)
520530
.map(|(stream, is_full)| {
521531
if stream.is_pending_open() && is_full {
@@ -576,6 +586,7 @@ where
576586
SendRequest {
577587
inner: self.inner.clone(),
578588
pending: None,
589+
profile: self.profile.clone(),
579590
}
580591
}
581592
}
@@ -663,9 +674,16 @@ impl Builder {
663674
settings: Default::default(),
664675
stream_id: 1.into(),
665676
local_max_error_reset_streams: Some(proto::DEFAULT_LOCAL_RESET_COUNT_MAX),
677+
_profile: AgentProfile::default(),
666678
}
667679
}
668680

681+
/// Use the profile to configure the client.
682+
pub fn profile(&mut self, profile: AgentProfile) -> &mut Self {
683+
self._profile = profile;
684+
self
685+
}
686+
669687
/// Indicates the initial window size (in octets) for stream-level
670688
/// flow control for received data.
671689
///
@@ -1321,7 +1339,7 @@ where
13211339

13221340
// Send initial settings frame
13231341
codec
1324-
.buffer(builder.settings.clone().into())
1342+
.buffer((builder.settings.clone(), builder._profile.clone()).into())
13251343
.expect("invalid SETTINGS frame");
13261344

13271345
let inner = proto::Connection::new(
@@ -1340,6 +1358,7 @@ where
13401358
let send_request = SendRequest {
13411359
inner: inner.streams().clone(),
13421360
pending: None,
1361+
profile: builder._profile,
13431362
};
13441363

13451364
let mut connection = Connection { inner };
@@ -1584,6 +1603,7 @@ impl Peer {
15841603
request: Request<()>,
15851604
protocol: Option<Protocol>,
15861605
end_of_stream: bool,
1606+
profile: AgentProfile,
15871607
) -> Result<Headers, SendError> {
15881608
use http::request::Parts;
15891609

@@ -1602,7 +1622,7 @@ impl Peer {
16021622

16031623
// Build the set pseudo header set. All requests will include `method`
16041624
// and `path`.
1605-
let mut pseudo = Pseudo::request(method, uri, protocol);
1625+
let mut pseudo = Pseudo::request(method, uri, protocol, profile);
16061626

16071627
if pseudo.scheme.is_none() {
16081628
// If the scheme is not set, then there are a two options.

‎src/codec/framed_write.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ where
257257
self.next = Some(Next::Continuation(continuation));
258258
}
259259
}
260-
Frame::Settings(v) => {
261-
v.encode(self.buf.get_mut());
260+
Frame::Settings(v, _profile) => {
261+
v.encode(self.buf.get_mut(), _profile);
262262
tracing::trace!(rem = self.buf.remaining(), "encoded settings");
263263
}
264264
Frame::GoAway(v) => {

0 commit comments

Comments
 (0)
Please sign in to comment.