Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,11 @@ private[http2] trait Http2StreamHandling extends GraphStageLogic with LogHelper
case _: WindowUpdateFrame =>
// We're not planning on sending any data on this stream anymore, so we don't care about window updates.
this
case rst: RstStreamFrame =>
val headers = ParsedHeadersFrame(rst.streamId, endStream = false, Seq((":status", "429")), None)
dispatchSubstream(headers, Right(Source.failed(new PeerClosedStreamException(rst.streamId, rst.errorCode))),
correlationAttributes)
Closed
Comment on lines +448 to +452
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I handle rst: RstStreamFrame is other states? should I change other places that handle RstStreamFrame to return the fake response?

case _ =>
expectIncomingStream(event, Closed, HalfClosedLocal(_), correlationAttributes)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,24 @@ class Http2ClientSpec extends PekkoSpecWithMaterializer("""
val dynamicTableUpdateTo8192 = ByteString(63, 225, 63)
headerPayload.take(3) shouldBe dynamicTableUpdateTo8192
})
"close stream if peer sends RST_STREAM frame with REFUSED_STREAM".inAssertAllStagesStopped(
new TestSetup with NetProbes {
val data = ByteString("abcd")
user.emitRequest(Post("/", HttpEntity(data)))
val TheStreamId = network.expect[HeadersFrame]().streamId
network.expectDATA(TheStreamId, endStream = true, data)

network.sendRST_STREAM(TheStreamId, ErrorCode.REFUSED_STREAM)

val response = user.expectResponse()
response.status should be(StatusCodes.TooManyRequests)

val entityDataIn = ByteStringSinkProbe(response.entity.dataBytes)
val error = entityDataIn.expectError()
error.getMessage shouldBe "Stream with ID [1] was closed by peer with code REFUSED_STREAM(0x07)"

connectionShouldStillBeUsable()
})
}

"support stream for response data" should {
Expand Down
Loading