Setting the content type to ANY
and changing the HttpBuilder content parsers to the text parser fixed the issue. The type of reader
in the response handler is now always java.io.InputStreamReader
.
Before:
def headerMap = [:]
//populate headers
def response = client.get("headers":headerMap)
After:
client.parser.'application/xml' = client.parser.'text/plain'
client.parser.'application/xhtml+xml' = client.parser.'text/plain'
client.parser.'application/atom+xml' = client.parser.'text/plain'
client.parser.'application/json' = client.parser.'text/plain'
client.parser.'text/html' = client.parser.'text/plain'
client.parser.'application/x-www-form-urlencoded' = client.parser.'text/plain'
def headerMap = [:]
//populate headers
def response = client.get("headers":headerMap, contentType:groovyx.net.http.ContentType.ANY)