Skip to content

Commit

Permalink
fix: send PROTOCOL_ERROR instead of REFUSED_STREAM for oversized headers
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Aug 5, 2024
1 parent 7dbb5c5 commit c011523
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/proto/streams/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,15 @@ impl Inner {

actions.send.schedule_implicit_reset(
stream,
Reason::REFUSED_STREAM,
Reason::PROTOCOL_ERROR,
counts,
&mut actions.task);

actions.recv.enqueue_reset_expiration(stream, counts);

Ok(())
} else {
Err(Error::library_reset(stream.id, Reason::REFUSED_STREAM))
Err(Error::library_reset(stream.id, Reason::PROTOCOL_ERROR))
}
},
Err(RecvHeaderBlockError::State(err)) => Err(err),
Expand Down
6 changes: 3 additions & 3 deletions tests/h2-tests/tests/client_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ async fn recv_too_big_headers() {
srv.send_frame(frames::headers(3).response(200)).await;
// no reset for 1, since it's closed anyway
// but reset for 3, since server hasn't closed stream
srv.recv_frame(frames::reset(3).refused()).await;
srv.recv_frame(frames::reset(3).protocol_error()).await;
idle_ms(10).await;
};

Expand All @@ -865,7 +865,7 @@ async fn recv_too_big_headers() {
// waiting for a response.
let req1 = tokio::spawn(async move {
let err = req1.expect("send_request").0.await.expect_err("response1");
assert_eq!(err.reason(), Some(Reason::REFUSED_STREAM));
assert_eq!(err.reason(), Some(Reason::PROTOCOL_ERROR));
});

let request = Request::builder()
Expand All @@ -876,7 +876,7 @@ async fn recv_too_big_headers() {
let req2 = client.send_request(request, true);
let req2 = tokio::spawn(async move {
let err = req2.expect("send_request").0.await.expect_err("response2");
assert_eq!(err.reason(), Some(Reason::REFUSED_STREAM));
assert_eq!(err.reason(), Some(Reason::PROTOCOL_ERROR));
});

let conn = tokio::spawn(async move {
Expand Down

0 comments on commit c011523

Please sign in to comment.