Skip to content

Commit

Permalink
sync w/ upstream(hyper): v1.5.1 => v1.5.2
Browse files Browse the repository at this point in the history
Changelog:

### v1.5.2 (2024-12-16)

#### Bug Fixes

* **http1:**
  * fix intermitent panic parsing partial headers (#3812) ([a131111f](hyperium/hyper@a131111), closes [#3811](hyperium/hyper#3811))
  * skip debug assertion of content length for HEAD responses (#3795) ([eaf2267c](hyperium/hyper@eaf2267), closes [#3794](hyperium/hyper#3794))

Release url: </~https://github.com/hyperium/hyper/releases/tag/v1.5.2>
Raw changelog: <hyperium/hyper@v1.5.1...v1.5.2>
  • Loading branch information
GlenDC committed Dec 27, 2024
1 parent 7845d74 commit 39708e1
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 10 deletions.
2 changes: 1 addition & 1 deletion FORK.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ as a distant relative.
### hyperium

- </~https://github.com/hyperium/h2/tree/v0.4.7>
- </~https://github.com/hyperium/hyper/tree/v1.5.1>
- </~https://github.com/hyperium/hyper/tree/v1.5.2>
- </~https://github.com/hyperium/hyper-util/tree/v0.1.10>

### tower-r
Expand Down
2 changes: 1 addition & 1 deletion rama-http-core/src/proto/h1/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ mod tests {
})
.await;
let desc = format!("read_size failed for {:?}", s);
state = result.unwrap_or_else(|_| panic!("{}", desc));
state = result.expect(&desc);
if state == ChunkedState::Body || state == ChunkedState::EndCr {
break;
}
Expand Down
4 changes: 4 additions & 0 deletions rama-http-core/src/proto/h1/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ where
return Poll::Ready(Err(crate::Error::new_too_large()));
}
if curr_len > 0 {
trace!("partial headers; {} bytes so far", curr_len);
self.partial_len = Some(curr_len);
} else {
// 1xx gobled some bytes
self.partial_len = None;
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion rama-http-core/src/proto/h1/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -667,12 +667,14 @@ impl Server {
#[cfg(debug_assertions)]
{
if let Some(len) = headers::content_length_parse(&value) {
assert!(
if msg.req_method != &Some(Method::HEAD) || known_len != 0 {
assert!(
len == known_len,
"payload claims content-length of {}, custom content-length header claims {}",
known_len,
len,
);
}
}
}

Expand Down
12 changes: 6 additions & 6 deletions rama-http-core/src/proto/h2/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
/// # BDP Algorithm
///
/// 1. When receiving a DATA frame, if a BDP ping isn't outstanding:
/// - 1a. Record current time.
/// - 1b. Send a BDP ping.
/// 1a. Record current time.
/// 1b. Send a BDP ping.
/// 2. Increment the number of received bytes.
/// 3. When the BDP ping ack is received:
/// - 3a. Record duration from sent time.
/// - 3b. Merge RTT with a running average.
/// - 3c. Calculate bdp as bytes/rtt.
/// - 3d. If bdp is over 2/3 max, set new max to bdp and update windows.
/// 3a. Record duration from sent time.
/// 3b. Merge RTT with a running average.
/// 3c. Calculate bdp as bytes/rtt.
/// 3d. If bdp is over 2/3 max, set new max to bdp and update windows.
use std::fmt;
use std::future::Future;
use std::pin::Pin;
Expand Down
57 changes: 57 additions & 0 deletions tests/http-core/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,63 @@ mod conn {
assert_eq!(vec, b"bar=foo");
}

#[tokio::test]
async fn client_100_then_http09() {
let (server, addr) = setup_std_test_server();

thread::spawn(move || {
let mut sock = server.accept().unwrap().0;
sock.set_read_timeout(Some(Duration::from_secs(5))).unwrap();
sock.set_write_timeout(Some(Duration::from_secs(5)))
.unwrap();
let mut buf = [0; 4096];
let _ = sock.read(&mut buf).expect("read 1");
sock.write_all(
b"\
HTTP/1.1 100 Continue\r\n\
Content-Type: text/plain\r\n\
Server: BaseHTTP/0.6 Python/3.12.5\r\n\
Date: Mon, 16 Dec 2024 03:08:27 GMT\r\n\
",
)
.unwrap();
// That it's separate writes is important to this test
thread::sleep(Duration::from_millis(50));
sock.write_all(
b"\
\r\n\
",
)
.expect("write 2");
thread::sleep(Duration::from_millis(50));
sock.write_all(
b"\
This is a sample text/plain document, without final headers.\
\n\n\
",
)
.expect("write 3");
});

let tcp = tcp_connect(&addr).await.unwrap();

let (mut client, conn) = conn::http1::Builder::new()
.http09_responses(true)
.handshake(tcp)
.await
.unwrap();

tokio::spawn(async move {
let _ = conn.await;
});

let req = Request::builder()
.uri("/a")
.body(Empty::<Bytes>::new())
.unwrap();
let _res = client.send_request(req).await.expect("send_request");
}

#[tokio::test]
async fn test_try_send_request() {
use std::future::Future;
Expand Down
2 changes: 1 addition & 1 deletion tests/http-core/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ fn header_name_too_long() {
let mut req = connect(server.addr());
let mut write = Vec::with_capacity(1024 * 66);
write.extend_from_slice(b"GET / HTTP/1.1\r\n");
write.resize(1024 * 65 - 1, b'x');
write.extend_from_slice(vec![b'x'; 1024 * 64].as_slice());
write.extend_from_slice(b": foo\r\n\r\n");
req.write_all(&write).unwrap();

Expand Down

0 comments on commit 39708e1

Please sign in to comment.