hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Content-Encoding header is missing in httpclient's response
Date Mon, 09 Dec 2013 11:11:02 GMT
On Mon, 2013-12-09 at 13:09 +0530, Dhruvakumar P G wrote:
> Hello,
> 
> I'm in the middle of upgrading Httpclient, mime, core libraries to 
> latest version. I haven't been able to figure out any solution to the 
> following problem.
> When Httpclient downloads a text file(icité Àâqë-withmultibytechars.txt) 
> which contains multibyte characters from another server and sends it to 
> the browser.
> *The server returns the response headers as below :*
> 
> HTTP/1.1 200 OK
> X-Powered-By: Servlet/2.5
> Content-Disposition: attachment;       filename="icité 
> Àâqë-withmultibytechars.txt"
> Content-Type: application/octet-stream
> Content-Length: 162
> *
> **Browser receives the headers as below and shows the filename rightly :*
> 
> Content-Disposition    attachment; filename="icité 
> Àâqë-withmultibytechars.txt"
> Content-Type    application/octet-stream
> Transfer-Encoding    chunked
> 
> When Httpclient downloads an image file(ウェ.jpg) from another server 
> and sends it to the browser.
> *The server returns the response headers as below : *
> HTTP/1.1 200 OK
> X-Powered-By: Servlet/2.5
> Content-Disposition: attachment; filename="ウェ.jpg"
> Content-Encoding: gzip
> Content-Type: application/octet-stream
> Transfer-Encoding: chunked
> 
> Even though  "Content-Encoding: gzip" header is returned by the server, 
> the response object doesn't have this header.
> Somehow this header has been removed from the response when the request 
> gets executed,  _response = _httpClient.execute(_httpHost, _httpMethod, 
> _httpContext);
> 
> *Browser will not receive this header, non-ascii characters aren't 
> recognized in the filename of download dialogue, it just shows empty 
> characters:*
> Content-Disposition    attachment; filename="   .jpg"
> Content-Type    application/octet-stream
> Transfer-Encoding    chunked, chunked
> 
> Am I missing something here ? How do I make sure that the Httpclient 
> doesn't ignore this header and browser get to show the filename rightly ?
> 

HTTP message headers may not have non-ASCII per requirements of the HTTP
protocol. The target server is in violation of the HTTP specification.

One can force HttpClient, though, to use a non-standard charset for HTTP
messages by using a custom ConnectionConfig.

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message