GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HTTP2: Always produce a RST frame on stream exception (#15352) · netty/netty@96b2daf

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • codec-http2/src/main/java/io/netty/handler/codec/http2
    • AbstractHttp2StreamChannel.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java‎

Copy file name to clipboardExpand all lines: codec-http2/src/main/java/io/netty/handler/codec/http2/AbstractHttp2StreamChannel.java
+17-8Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -705,10 +705,10 @@ public void disconnect(ChannelPromise promise) {
705705

706706
@Override
707707
public void close(final ChannelPromise promise) {
708-
close(promise, Http2Error.CANCEL);
708+
close(promise, null);
709709
}
710710

711-
void close(final ChannelPromise promise, Http2Error error) {
711+
private void close(final ChannelPromise promise, Http2Error error) {
712712
if (!promise.setUncancellable()) {
713713
return;
714714
}
@@ -738,12 +738,21 @@ public void operationComplete(ChannelFuture future) {
738738

739739
// Only ever send a reset frame if the connection is still alive and if the stream was created before
740740
// as otherwise we may send a RST on a stream in an invalid state and cause a connection error.
741-
if (parent().isActive() && isStreamIdValid(stream.id()) &&
742-
// Also ensure the stream was never "closed" before.
743-
!readEOS && !(receivedEndOfStream && sentEndOfStream)) {
744-
Http2StreamFrame resetFrame = new DefaultHttp2ResetFrame(error).stream(stream());
745-
write(resetFrame, unsafe().voidPromise());
746-
flush();
741+
if (parent().isActive() && isStreamIdValid(stream.id())) {
742+
// If error is null we know that the close was not triggered by an error and so we should only
743+
// try to send a RST frame if we didn't signal the end of the stream before.
744+
if (error == null) {
745+
if (!readEOS && !(receivedEndOfStream && sentEndOfStream)) {
746+
Http2StreamFrame resetFrame = new DefaultHttp2ResetFrame(Http2Error.CANCEL).stream(stream());
747+
write(resetFrame, unsafe().voidPromise());
748+
flush();
749+
}
750+
} else {
751+
// Close was triggered by a stream error, in this case we always want to send a RST frame.
752+
Http2StreamFrame resetFrame = new DefaultHttp2ResetFrame(error).stream(stream());
753+
write(resetFrame, unsafe().voidPromise());
754+
flush();
755+
}
747756
}
748757

749758
if (inboundBuffer != null) {

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.