Skip to content

Commit

Permalink
Merge pull request #1375 from softwaremill/play-headers
Browse files Browse the repository at this point in the history
Added filtering of implicit headers for Play
  • Loading branch information
adamw authored Jul 15, 2021
2 parents 776e8c2 + 445d8ca commit 763e8b7
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,22 @@ trait PlayServerInterpreter {
case (key, value) if key == HeaderNames.SET_COOKIE => (key, value.mkString(";;"))
case (key, value) => (key, value.mkString(", "))
}
val status = response.code.code
.filterNot(allowToSetExplicitly)

val status = response.code.code
response.body match {
case Some(entity) =>
val result = Result(ResponseHeader(status, headers), entity)
headers.find(_._1.toLowerCase == "content-type").map(ct => result.as(ct._2)).getOrElse(result)
case Some(entity) => Result(ResponseHeader(status, headers), entity)
case None => Result(ResponseHeader(status, headers), HttpEntity.NoEntity)
}
}
}
}
}
}

private def allowToSetExplicitly[O, E, I](header: (String, String)): Boolean =
List(HeaderNames.CONTENT_TYPE, HeaderNames.CONTENT_LENGTH, HeaderNames.TRANSFER_ENCODING).contains(header._1)

}

object PlayServerInterpreter {
Expand Down

0 comments on commit 763e8b7

Please sign in to comment.