From 0425a9726462da6fc8fe7ab767a05c2a37fb23d9 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Thu, 2 Jul 2015 21:20:36 +1000 Subject: [PATCH] guard against requests with no content type --- .../au/com/dius/pact/model/unfiltered/Conversions.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pact-jvm-model/src/main/scala/au/com/dius/pact/model/unfiltered/Conversions.scala b/pact-jvm-model/src/main/scala/au/com/dius/pact/model/unfiltered/Conversions.scala index 6b11c649df..878c9da0ee 100644 --- a/pact-jvm-model/src/main/scala/au/com/dius/pact/model/unfiltered/Conversions.scala +++ b/pact-jvm-model/src/main/scala/au/com/dius/pact/model/unfiltered/Conversions.scala @@ -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) }