async-http-client
async-http-client copied to clipboard
Enforcing charset in Content-Type is evil
Sometimes AHC is used to interact with crappy servers and full control over headers is required.
In AHC 2.1 Content-Type header is modified regardless of my input:
httpClient.preparePost(authenticationUrl)
.setBody(byte[])
.setCharset(null)
.setHeader("Content-Type", "text/xml")
.execute()
sends content-type: text/xml; charset=UTF-8 which freaks out the server.
I suggest having two distinct approaches:
setContentTypewithsetCharsetthat generate this headersetHeader("Content-Type", "text/xml")that overrides whatever was generated
This would be more transparent and flexible.
For now, I will have to rebuild my request using constructor.
See 751a818ff60a263dd3965a9236ac9c8a6e061934
This also breaks aws-signature generation whenever the signature is calculated before the headers are finalized/altered.