diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala index b5bd371965..b2d440a172 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpMessageParser.scala @@ -170,11 +170,11 @@ private[http] abstract class HttpMessageParser[Output >: MessageOutput <: Parser val remainingInputBytes = input.length - bodyStart if (remainingInputBytes > 0) { if (remainingInputBytes < remainingBodyBytes) { - emit(EntityPart(input drop bodyStart)) + emit(EntityPart(input.drop(bodyStart).compact)) continue(parseFixedLengthBody(remainingBodyBytes - remainingInputBytes, isLastMessage)) } else { val offset = bodyStart + remainingBodyBytes.toInt - emit(EntityPart(input.slice(bodyStart, offset))) + emit(EntityPart(input.slice(bodyStart, offset).compact)) emit(MessageEnd) setCompletionHandling(CompletionOk) if (isLastMessage) terminate() @@ -211,7 +211,7 @@ private[http] abstract class HttpMessageParser[Output >: MessageOutput <: Parser if (chunkSize > 0) { val chunkBodyEnd = cursor + chunkSize def result(terminatorLen: Int) = { - emit(EntityChunk(HttpEntity.Chunk(input.slice(cursor, chunkBodyEnd), extension))) + emit(EntityChunk(HttpEntity.Chunk(input.slice(cursor, chunkBodyEnd).compact, extension))) Trampoline(_ ⇒ parseChunk(input, chunkBodyEnd + terminatorLen, isLastMessage)) } byteChar(input, chunkBodyEnd) match { diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpResponseParser.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpResponseParser.scala index 7922a3e1e8..4751f68123 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpResponseParser.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/parsing/HttpResponseParser.scala @@ -132,7 +132,7 @@ private[http] class HttpResponseParser(_settings: ParserSettings, _headerParser: // currently we do not check for `settings.maxContentLength` overflow def parseToCloseBody(input: ByteString, bodyStart: Int): StateResult = { if (input.length > bodyStart) - emit(EntityPart(input drop bodyStart)) + emit(EntityPart(input.drop(bodyStart).compact)) continue(parseToCloseBody) } } \ No newline at end of file diff --git a/akka-http-core/src/main/scala/akka/http/impl/engine/ws/FrameEventParser.scala b/akka-http-core/src/main/scala/akka/http/impl/engine/ws/FrameEventParser.scala index 86ae74d01d..927b2a3a67 100644 --- a/akka-http-core/src/main/scala/akka/http/impl/engine/ws/FrameEventParser.scala +++ b/akka-http-core/src/main/scala/akka/http/impl/engine/ws/FrameEventParser.scala @@ -87,7 +87,7 @@ private[http] class FrameEventParser extends ByteStringParserStage[FrameEvent] { if (thisFrameData.length == length) ReadFrameHeader else readData(length - thisFrameData.length) - pushAndBecomeWithRemaining(FrameStart(header, thisFrameData), nextState, remaining, ctx) + pushAndBecomeWithRemaining(FrameStart(header, thisFrameData.compact), nextState, remaining, ctx) } } @@ -103,7 +103,7 @@ private[http] class FrameEventParser extends ByteStringParserStage[FrameEvent] { val frameData = elem.take(remaining.toInt) val remainingData = elem.drop(remaining.toInt) - pushAndBecomeWithRemaining(FrameData(frameData, lastPart = true), ReadFrameHeader, remainingData, ctx) + pushAndBecomeWithRemaining(FrameData(frameData.compact, lastPart = true), ReadFrameHeader, remainingData, ctx) } }