From d46130d76f75db8a974bdc5c78b8ef088c555dbf Mon Sep 17 00:00:00 2001 From: Johannes Rudolph Date: Mon, 28 Oct 2019 12:59:10 +0100 Subject: [PATCH] core: improve "Entity stream truncation" error message Refs #2786 --- .../akka/http/impl/engine/parsing/HttpMessageParser.scala | 4 +++- .../http/impl/engine/client/ResponseParsingMergeSpec.scala | 2 +- .../akka/http/impl/engine/parsing/ResponseParserSpec.scala | 2 +- .../scala/akka/http/impl/engine/server/HttpServerSpec.scala | 4 ++-- 4 files changed, 7 insertions(+), 5 deletions(-) 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 bc92a7ccba2..d16ae359c79 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 @@ -374,5 +374,7 @@ private[http] object HttpMessageParser { val CompletionIsMessageStartError: CompletionHandling = () => Some(ParserOutput.MessageStartError(StatusCodes.BadRequest, ErrorInfo("Illegal HTTP message start"))) val CompletionIsEntityStreamError: CompletionHandling = - () => Some(ParserOutput.EntityStreamError(ErrorInfo("Entity stream truncation"))) + () => Some(ParserOutput.EntityStreamError(ErrorInfo( + "Entity stream truncation. The HTTP parser was receiving an entity when the underlying connection was " + + "closed unexpectedly."))) } diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/client/ResponseParsingMergeSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/client/ResponseParsingMergeSpec.scala index 2ab423922df..85baab2aad2 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/client/ResponseParsingMergeSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/client/ResponseParsingMergeSpec.scala @@ -95,7 +95,7 @@ class ResponseParsingMergeSpec extends AkkaSpec { responseProbe.expectComplete() responseChunks.last shouldBe an[EntityStreamError] - responseChunks.last shouldEqual EntityStreamError(ErrorInfo("Entity stream truncation")) + responseChunks.last shouldEqual EntityStreamError(ErrorInfo("Entity stream truncation. The HTTP parser was receiving an entity when the underlying connection was closed unexpectedly.")) } } diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala index fca21ed83f5..dfd5b32fd74 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/parsing/ResponseParserSpec.scala @@ -240,7 +240,7 @@ abstract class ResponseParserSpec(mode: String, newLine: String) extends FreeSpe Right(HttpResponse( headers = List(`Transfer-Encoding`(TransferEncodings.Extension("fancy"))), entity = HttpEntity.Chunked(`application/pdf`, source()))), - Left(EntityStreamError(ErrorInfo("Entity stream truncation")))) + Left(EntityStreamError(ErrorInfo("Entity stream truncation. The HTTP parser was receiving an entity when the underlying connection was closed unexpectedly.")))) closeAfterResponseCompletion shouldEqual Seq(false) } diff --git a/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerSpec.scala b/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerSpec.scala index 8f57d9e0396..d4849148a68 100644 --- a/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerSpec.scala +++ b/akka-http-core/src/test/scala/akka/http/impl/engine/server/HttpServerSpec.scala @@ -425,7 +425,7 @@ class HttpServerSpec extends AkkaSpec( dataProbe.expectNext(ByteString("abcdef")) dataProbe.expectNoMessage(50.millis) closeNetworkInput() - dataProbe.expectError().getMessage shouldEqual "Entity stream truncation" + dataProbe.expectError().getMessage shouldEqual "Entity stream truncation. The HTTP parser was receiving an entity when the underlying connection was closed unexpectedly." } shutdownBlueprint() }) @@ -447,7 +447,7 @@ class HttpServerSpec extends AkkaSpec( dataProbe.expectNext(Chunk(ByteString("abcdef"))) dataProbe.expectNoMessage(50.millis) closeNetworkInput() - dataProbe.expectError().getMessage shouldEqual "Entity stream truncation" + dataProbe.expectError().getMessage shouldEqual "Entity stream truncation. The HTTP parser was receiving an entity when the underlying connection was closed unexpectedly." } shutdownBlueprint() })