groovy-wslite
groovy-wslite copied to clipboard
HTTPClient.defaultCharset is ignored in case of charset is not specified in content type header,
Hi,
I'm trying to use groovy-wslite instead of httpbuilder because of convenient APIs. My example Korean site ( http://clien.net/ ) is encoded to 'UTF-8' but charset isn't specified in content type header. So it is converted 'iso-8859-1' by default in HttpResponse.getContentAsString(). This response text would be unreadable for Korean.
In this case, if user set defaultCharset of HTTPClient as 'UTF-8', can it be used in HttpResponse.getContentAsString() with defaultCharset?
Thanks in advance.
Best Regards, Thomas
Here is an example:
def url = "http://clien.net"
def client = new RESTClient(url)
client.defaultCharset = "UTF-8"
def response = client.get()
// response.charset is null
println "response.charset=" + response.charset
// response.text is converted to 'iso-8859-1' from 'UTF-8',
println "response.text=" + response.text
Here is my quick fix.
https://github.com/yeoupooh/groovy-wslite/tree/issue100_patch