From e4d1ccd06f32f286e0515f43497b9f41d9e8142c Mon Sep 17 00:00:00 2001 From: kcsham Date: Thu, 24 May 2018 17:59:05 -0700 Subject: [PATCH] Correct content-length generation for JSON Use correct HttpEntity to report Content-Length. --- .../swagger-play2/app/controllers/ApiHelpController.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/play-2.6/swagger-play2/app/controllers/ApiHelpController.scala b/play-2.6/swagger-play2/app/controllers/ApiHelpController.scala index a610fe4..42d85a7 100644 --- a/play-2.6/swagger-play2/app/controllers/ApiHelpController.scala +++ b/play-2.6/swagger-play2/app/controllers/ApiHelpController.scala @@ -204,8 +204,8 @@ trait SwaggerBaseApiController { val jsonBytes = toJsonString(data).getBytes("UTF-8") val source = Source.single(jsonBytes).map(ByteString.apply) Result ( - header = ResponseHeader(200, Map(HeaderNames.CONTENT_LENGTH -> jsonBytes.length.toString)), - body = HttpEntity.Streamed(source, None, None) - ).as ("application/json") + header = ResponseHeader(200, Map.empty), + body = HttpEntity.Streamed(source, Some(jsonBytes.length), Some("application/json")) + ) } }