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 @@ -297,7 +297,7 @@ private[http] trait HttpMessageParser[Output >: MessageOutput <: ParserOutput] {
case EmptyHeader =>
val lastChunk =
if (extension.isEmpty && headers.isEmpty) HttpEntity.LastChunk
else HttpEntity.LastChunk(extension, headers)
else HttpEntity.LastChunk(extension, headers.reverse)
emit(EntityChunk(lastChunk))
emit(MessageEnd)
setCompletionHandling(CompletionOk)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,37 @@ abstract class ResponseParserSpec(mode: String, newLine: String) extends PekkoSp
closeAfterResponseCompletion shouldEqual Seq(false)
}

if (mode == "CRLF") {
"preserve trailer field order in parser output" in new Test {
val input = crlf("""HTTP/1.1 200 OK
|Transfer-Encoding: chunked
|Content-Type: application/octet-stream
|Trailer: X-Menu-Order, X-Menu-Note
|
|4
|menu
|0
|X-Menu-Order: starter
|X-Menu-Note: seasonal
|X-Menu-Order: dessert
|
|""")
// X-Menu-Order is an application list-valued field. Its repeated lines stay separate and ordered.
val expectedTrailers = List(
RawHeader("X-Menu-Order", "starter"),
RawHeader("X-Menu-Note", "seasonal"),
RawHeader("X-Menu-Order", "dessert"))
val outputs = collectBlocking(
Source.single(SessionBytes(TLSPlacebo.dummySession, ByteString(input))).via(newParserStage()))
.filterNot(_ == NeedNextRequestMethod)
outputs.head shouldBe a[ResponseStart]
outputs.tail shouldEqual Seq(
EntityChunk(Chunk(ByteString("menu"))),
EntityChunk(LastChunk(trailer = expectedTrailers)),
MessageEnd)
}
}

"message end with extension, trailer and remaining content" in new Test {
Seq(
prep(start),
Expand Down