Skip to content
Open
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 @@ -343,6 +343,37 @@ abstract class ResponseParserSpec(mode: String, newLine: String) extends PekkoSp
closeAfterResponseCompletion shouldEqual Seq(false)
}

"retain a declared response trailer when the terminating empty line arrives separately" in new Test {
val field = RawHeader("X-Trace", "complete")
val declaration = headers.Trailer(Seq(field.name))
val terminalChunk = LastChunk(trailer = List(field))
val responseStart = prep(s"""HTTP/1.1 200 OK
|Transfer-Encoding: chunked
|Content-Type: application/pdf
|Trailer: ${field.name}
|
|""")
// The header section follows the suite mode; chunk framing uses CRLF in both modes.
val beforeEmptyLine = responseStart + crlf(s"""0
|${field.name}: ${field.value}
|""")

val parsed = collectBlocking(
Source(List(beforeEmptyLine, crlf("\n")))
.map(input => SessionBytes(TLSPlacebo.dummySession, ByteString(input)))
.via(newParserStage())
.filterNot(_ == NeedNextRequestMethod))

parsed match {
case Seq(ResponseStart(status, protocol, _, headers, _, _), EntityChunk(chunk), MessageEnd) =>
status shouldBe OK
protocol shouldBe `HTTP/1.1`
headers should contain(declaration)
chunk shouldBe terminalChunk
case other => fail(s"Expected a response start, one terminal chunk and a message end, got ${other}")
}
}

"message end" in new Test {
Seq(
prep(start),
Expand Down