Skip to content

Commit

Permalink
guard against requests with no content type
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Jul 2, 2015
1 parent 2c03a20 commit 0425a97
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ object Conversions {
}

implicit def dispatchResponseToPactResponse(response: client.Response): Response = {
val contentType = org.apache.http.entity.ContentType.parse(response.getContentType)
val contentType = if (response.getContentType == null)
org.apache.http.entity.ContentType.APPLICATION_JSON
else
org.apache.http.entity.ContentType.parse(response.getContentType)
val charset = if (contentType.getCharset == null) "UTF-8" else contentType.getCharset.name()
Response(response.getStatusCode, Some(toMap(response.getHeaders)), Some(response.getResponseBody(charset)), None)
}
Expand Down

0 comments on commit 0425a97

Please sign in to comment.