Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3F99F10ABC for ; Mon, 9 Dec 2013 13:46:39 +0000 (UTC) Received: (qmail 46444 invoked by uid 500); 9 Dec 2013 13:46:39 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 46241 invoked by uid 500); 9 Dec 2013 13:46:25 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 46224 invoked by uid 99); 9 Dec 2013 13:46:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Dec 2013 13:46:22 +0000 X-ASF-Spam-Status: No, hits=1.6 required=5.0 tests=FSL_NEW_HELO_USER,HTML_MESSAGE,RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of dhruvakumar.p.g@oracle.com designates 156.151.31.81 as permitted sender) Received: from [156.151.31.81] (HELO userp1040.oracle.com) (156.151.31.81) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Dec 2013 13:46:13 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id rB9Djoio031085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 9 Dec 2013 13:45:51 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rB9Djnvv017702 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 9 Dec 2013 13:45:50 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id rB9Djn8P017688; Mon, 9 Dec 2013 13:45:49 GMT Received: from [10.178.246.47] (/10.178.246.47) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 09 Dec 2013 05:45:49 -0800 Message-ID: <52A5C98D.2050909@oracle.com> Date: Mon, 09 Dec 2013 19:15:49 +0530 From: Dhruvakumar P G Organization: Oracle Corporation User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20131028 Thunderbird/17.0.10 MIME-Version: 1.0 To: HttpComponents Project CC: Oleg Kalnichevski Subject: Re: Content-Encoding header is missing in httpclient's response References: <52A5739E.1020400@oracle.com> <1386587462.24937.7.camel@ubuntu> In-Reply-To: <1386587462.24937.7.camel@ubuntu> Content-Type: multipart/alternative; boundary="------------020702050000020607090601" X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-Virus-Checked: Checked by ClamAV on apache.org --------------020702050000020607090601 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 12/9/2013 4:41 PM, Oleg Kalnichevski wrote: > 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. Yes indeed, the target server should return encoded filename : *Content-disposition: attachment; filename="=?utf-8?B?44Km44KnLmpwZw==?="* But instead it is returning unencoded filename : Content-Disposition: attachment; filename="ウェ.jpg" Can't I resolve my issue unless target server returns encoded filename ? Thanks, Dhruva > One can force HttpClient, though, to use a non-standard charset for HTTP > messages by using a custom ConnectionConfig. > > Oleg > I have set the charset to UTF-8, connectionConfigBuilder.setCharset(Consts.UTF_8) Will Setting charset to any other make httpclient to not to lose 'Content-Encoding' response header ? Thanks, Dhruva > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org > For additional commands, e-mail: dev-help@hc.apache.org > --------------020702050000020607090601--