Skip to content

Commit

Permalink
Fail when status = NoContent but there's a body
Browse files Browse the repository at this point in the history
  • Loading branch information
kciesielski committed Aug 7, 2023
1 parent 425d65c commit 2380053
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ class ServerInterpreter[R, F[_], B, S](
val statusCode = outputValues.statusCode.getOrElse(defaultStatusCode)

val headers = outputValues.headers
outputValues.body match {
case Some(bodyFromHeaders) => ServerResponse(statusCode, headers, Some(bodyFromHeaders(Headers(headers))), Some(output)).unit
case None => ServerResponse(statusCode, headers, None: Option[B], Some(output)).unit
(statusCode, outputValues.body) match {
case (StatusCode.NoContent, Some(_)) => monad.error(new IllegalStateException("Unexpected response body when status code == NoContent (204)"))
case (_, Some(bodyFromHeaders)) => ServerResponse(statusCode, headers, Some(bodyFromHeaders(Headers(headers))), Some(output)).unit
case (_, None) => ServerResponse(statusCode, headers, None: Option[B], Some(output)).unit
}
}
}
Expand Down

0 comments on commit 2380053

Please sign in to comment.