rp-arielrodriguez opened a new pull request, #710:
URL: https://github.com/apache/httpcomponents-core/pull/710

   We found this with HTTP/2 multiplexing in HttpClient 5: when a GET timed out
   on a shared connection and the server stayed silent, no RST_STREAM was sent.
   The server kept working on the request, and the stream kept its slot.
   
   `H2Stream#abort()` sets `cancelled` and calls `requestOutput()`, but the 
flag is
   checked only in `consumeHeader`, `consumeData` and `consumePromise`. The 
output
   loop in `AbstractH2StreamMultiplexer#produceOutput` skips streams that are
   local-closed, so a half-closed stream with a silent peer is never reset.
   
   Changes:
   
   - `H2Stream` owns the cancel state. `isOutputAllowed()` and `isOutputReady()`
     return `true` when a cancel is pending, and `produceOutput()` sends
     RST_STREAM(CANCEL) in that case. The multiplexer loops call these methods
     instead of repeating the closed/reserved/window checks. The inbound-frame
     checks stay as they are.
   - A stream cancelled before its HEADERS are sent is idle (RFC 9113 section 
5.1).
     RST_STREAM on an idle stream is a connection error, so the stream is closed
     locally with no frame. `H2StreamChannel#isIdle()` tracks this; `submit()`
     and `push()` clear it.
   
   Known limit: `produceOutput()` runs only while the connection output window 
is
   open and the remote SETTINGS are acknowledged. RST_STREAM is not flow
   controlled, so it could be sent in more cases. I kept the existing gate to 
keep
   the change small.
   
   Backport: the same code is in 5.4.x. I can open a backport PR if you want 
one.
   
   Tests:
   
   - New: 
`TestAbstractH2StreamMultiplexer#testAbortAfterLocalEndStreamSendsRstStreamWithoutInboundFrames`
     (fails on master, passes with the fix).
   - New: 
`TestAbstractH2StreamMultiplexer#testAbortBeforeHeadersSendsNoFramesForIdleStream`.
   - `./mvnw -pl httpcore5-testing -am test`: httpcore5 1960, httpcore5-h2 388,
     httpcore5-testing 443 (4 skipped), all pass. Checkstyle and RAT pass.
   
   I used an AI assistant (Claude Code) for this change. I reviewed all of it 
and
   I can answer questions about it.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to