=htc improve error messages
This commit is contained in:
parent
5562ceb94b
commit
bca5626fbd
2 changed files with 4 additions and 4 deletions
|
|
@ -68,13 +68,13 @@ private object RenderSupport {
|
|||
def onNext(elem: ByteString): List[ByteString] = {
|
||||
sent += elem.length
|
||||
if (sent > length)
|
||||
throw new InvalidContentLengthException(s"HTTP message had declared Content-Length $length but entity chunk stream amounts to more bytes")
|
||||
throw new InvalidContentLengthException(s"HTTP message had declared Content-Length $length but entity data stream amounts to more bytes")
|
||||
elem :: Nil
|
||||
}
|
||||
|
||||
override def onTermination(e: Option[Throwable]): List[ByteString] = {
|
||||
if (sent < length)
|
||||
throw new InvalidContentLengthException(s"HTTP message had declared Content-Length $length but entity chunk stream amounts to ${length - sent} bytes less")
|
||||
throw new InvalidContentLengthException(s"HTTP message had declared Content-Length $length but entity data stream amounts to ${length - sent} bytes less")
|
||||
Nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,14 +141,14 @@ class ResponseRendererSpec extends FreeSpec with Matchers with BeforeAndAfterAll
|
|||
the[RuntimeException] thrownBy {
|
||||
HttpResponse(200, entity = Default(ContentTypes.`application/json`, 10,
|
||||
source(ByteString("body123")))) should renderTo("")
|
||||
} should have message "HTTP message had declared Content-Length 10 but entity chunk stream amounts to 3 bytes less"
|
||||
} should have message "HTTP message had declared Content-Length 10 but entity data stream amounts to 3 bytes less"
|
||||
}
|
||||
|
||||
"one chunk and incorrect (too small) Content-Length" in new TestSetup() {
|
||||
the[RuntimeException] thrownBy {
|
||||
HttpResponse(200, entity = Default(ContentTypes.`application/json`, 5,
|
||||
source(ByteString("body123")))) should renderTo("")
|
||||
} should have message "HTTP message had declared Content-Length 5 but entity chunk stream amounts to more bytes"
|
||||
} should have message "HTTP message had declared Content-Length 5 but entity data stream amounts to more bytes"
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue