Re: Issue with deflate Content-Encode httpClient 4.1.3

2018-12-20 Thread Oleg Kalnichevski
On Thu, 2018-12-20 at 10:04 +, Khare, Aparna wrote:
> Hi Oleg,
> 
>  Actually we cannot move from HttpClient 4.1.3 can we get this fixed
> here ...or if there is a workaround..
> 

Of course, there is. Just back-port content decompression code from
4.5 to 4.1.

Oleg

> Thanks,
> Aparna
> 
> -Original Message-
> From: Oleg Kalnichevski  
> Sent: Thursday, December 20, 2018 3:18 PM
> To: Khare, Aparna ; HttpClient User Discussion
> 
> Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3
> 
> On Thu, 2018-12-20 at 08:20 +, Khare, Aparna wrote:
> > Hi Oleg,
> > 
> >https://httpbin.davecheney.com/deflate
> > 
> > I'm trying to do an GET  the response for the above url.
> > 
> > if (response.getEntity() != null) {
> > InputStream  inStream = response.getEntity().getContent();
> > 
> > if (inStream != null) {
> >   try {
> > ByteArrayOutputStream outStream = new
> > ByteArrayOutputStream();
> > int value = inStream.read();
> > while (value != -1) {
> >   outStream.write(value);
> >   value = inStream.read();
> > }
> > response = outStream.toByteArray();
> >   } 
> > }
> > Finally this data is required to be parsed on UI where we are using
> > 
> > Both deflated content and gZip data is malformed once the response
> > is
> > returned ..(Encoding issue)
> > 
> > How can I get this fixed. 
> > 
> > Thanks,
> > Aparna
> > 
> 
> Works with HttpClient 4.5
> 
> Oleg
> 
> [DEBUG] RequestAddCookies - CookieSpec selected: default
> [DEBUG] RequestAuthCache - Auth cache not set in the context
> [DEBUG] PoolingHttpClientConnectionManager - Connection request:
> [route: {s}->https://httpbin.davecheney.com:443][total kept alive: 0;
> route allocated: 0 of 2; total allocated: 0 of 20]
> [DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id:
> 0][route: {s}->https://httpbin.davecheney.com:443][total kept alive:
> 0; route allocated: 1 of 2; total allocated: 1 of 20]
> [DEBUG] MainClientExec - Opening connection {s}->
> https://httpbin.davecheney.com:443
> [DEBUG] DefaultHttpClientConnectionOperator - Connecting to
> httpbin.davecheney.com/35.189.26.87:443
> [DEBUG] SSLConnectionSocketFactory - Connecting socket to
> httpbin.davecheney.com/35.189.26.87:443 with timeout 0
> [DEBUG] SSLConnectionSocketFactory - Enabled protocols: [TLSv1,
> TLSv1.1, TLSv1.2]
> [DEBUG] SSLConnectionSocketFactory - Enabled cipher
> suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384,
> TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
> TLS_RSA_WITH_AES_256_CBC_SHA256,
> TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384,
> TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384,
> TLS_DHE_RSA_WITH_AES_256_CBC_SHA256,
> TLS_DHE_DSS_WITH_AES_256_CBC_SHA256,
> TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
> TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA,
> TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA,
> TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA,
> TLS_DHE_DSS_WITH_AES_256_CBC_SHA,
> TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
> TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
> TLS_RSA_WITH_AES_128_CBC_SHA256,
> TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256,
> TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256,
> TLS_DHE_RSA_WITH_AES_128_CBC_SHA256,
> TLS_DHE_DSS_WITH_AES_128_CBC_SHA256,
> TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
> TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA,
> TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA,
> TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
> TLS_DHE_DSS_WITH_AES_128_CBC_SHA,
> TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
> TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
> TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
> TLS_RSA_WITH_AES_256_GCM_SHA384,
> TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384,
> TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384,
> TLS_DHE_RSA_WITH_AES_256_GCM_SHA384,
> TLS_DHE_DSS_WITH_AES_256_GCM_SHA384,
> TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
> TLS_RSA_WITH_AES_128_GCM_SHA256,
> TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256,
> TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256,
> TLS_DHE_RSA_WITH_AES_128_GCM_SHA256,
> TLS_DHE_DSS_WITH_AES_128_GCM_SHA256,
> TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
> [DEBUG] SSLConnectionSocketFactory - Starting handshake
> [DEBUG] SSLConnectionSocketFactory - Secure session established
> [DEBUG] SSLConnectionSocketFactory -  negotiated protocol: TLSv1.2
> [DEBUG] SSLConnectionSocketFactory -  negotiated cipher suite:
> TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
> [DEBUG] SSLConnectionSocketFactory -  peer principal:
> CN=httpbin.davecheney.com
> [DEBUG] SSLConnectionSocketFactory -  peer alternat

RE: Issue with deflate Content-Encode httpClient 4.1.3

2018-12-20 Thread Khare, Aparna
Hi Oleg,

 Actually we cannot move from HttpClient 4.1.3 can we get this fixed here ...or 
if there is a workaround..

Thanks,
Aparna

-Original Message-
From: Oleg Kalnichevski  
Sent: Thursday, December 20, 2018 3:18 PM
To: Khare, Aparna ; HttpClient User Discussion 

Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3

On Thu, 2018-12-20 at 08:20 +, Khare, Aparna wrote:
> Hi Oleg,
> 
>https://httpbin.davecheney.com/deflate
> 
> I'm trying to do an GET  the response for the above url.
> 
> if (response.getEntity() != null) {
> InputStream  inStream = response.getEntity().getContent();
> 
> if (inStream != null) {
>   try {
> ByteArrayOutputStream outStream = new
> ByteArrayOutputStream();
> int value = inStream.read();
> while (value != -1) {
>   outStream.write(value);
>   value = inStream.read();
> }
> response = outStream.toByteArray();
>   } 
> }
> Finally this data is required to be parsed on UI where we are using
> 
> Both deflated content and gZip data is malformed once the response is
> returned ..(Encoding issue)
> 
> How can I get this fixed. 
> 
> Thanks,
> Aparna
> 

Works with HttpClient 4.5

Oleg

[DEBUG] RequestAddCookies - CookieSpec selected: default
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] PoolingHttpClientConnectionManager - Connection request: [route: 
{s}->https://httpbin.davecheney.com:443][total kept alive: 0; route allocated: 
0 of 2; total allocated: 0 of 20]
[DEBUG] PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: 
{s}->https://httpbin.davecheney.com:443][total kept alive: 0; route allocated: 
1 of 2; total allocated: 1 of 20]
[DEBUG] MainClientExec - Opening connection 
{s}->https://httpbin.davecheney.com:443
[DEBUG] DefaultHttpClientConnectionOperator - Connecting to 
httpbin.davecheney.com/35.189.26.87:443
[DEBUG] SSLConnectionSocketFactory - Connecting socket to 
httpbin.davecheney.com/35.189.26.87:443 with timeout 0
[DEBUG] SSLConnectionSocketFactory - Enabled protocols: [TLSv1, TLSv1.1, 
TLSv1.2]
[DEBUG] SSLConnectionSocketFactory - Enabled cipher 
suites:[TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, 
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_RSA_WITH_AES_256_CBC_SHA256, 
TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA384, 
TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, 
TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, 
TLS_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, 
TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, 
TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, 
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_CBC_SHA256, 
TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA256, 
TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, 
TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 
TLS_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, 
TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, 
TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, 
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, 
TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDH_ECDSA_WITH_AES_256_GCM_SHA384, 
TLS_ECDH_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, 
TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, 
TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, 
TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, 
TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
[DEBUG] SSLConnectionSocketFactory - Starting handshake
[DEBUG] SSLConnectionSocketFactory - Secure session established
[DEBUG] SSLConnectionSocketFactory -  negotiated protocol: TLSv1.2
[DEBUG] SSLConnectionSocketFactory -  negotiated cipher suite: 
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
[DEBUG] SSLConnectionSocketFactory -  peer principal: CN=httpbin.davecheney.com
[DEBUG] SSLConnectionSocketFactory -  peer alternative names: 
[httpbin.davecheney.com]
[DEBUG] SSLConnectionSocketFactory -  issuer principal: CN=Let's Encrypt 
Authority X3, O=Let's Encrypt, C=US
[DEBUG] DefaultHttpClientConnectionOperator - Connection established 
192.168.43.142:57358<->35.189.26.87:443
[DEBUG] MainClientExec - Executing request GET /deflate HTTP/1.1
[DEBUG] MainClientExec - Target auth state: UNCHALLENGED
[DEBUG] MainClientExec - Proxy auth state: UNCHALLENGED
[DEBUG] headers - http-outgoing-0 >> GET /deflate HTTP/1.1
[DEBUG] headers - http-outgoing-0 >> Host: httpbin.davecheney.com
[DEBUG] headers - http-outgoing-0 >> Connection: Keep-Alive
[DEBUG] headers - http-outgoing-0 >> User-Agent: Apach

Re: Issue with deflate Content-Encode httpClient 4.1.3

2018-12-20 Thread Oleg Kalnichevski
-Alive[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.5.6 
(Java/1.8.0_181)[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "Accept-Encoding: gzip,deflate[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "server: envoy[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "date: Thu, 20 Dec 2018 09:46:40 GMT[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "content-type: application/json[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "content-length: 280[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "content-encoding: deflate[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "access-control-allow-origin: *[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "access-control-allow-credentials: 
true[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "x-envoy-upstream-service-time: 3[\r][\n]"
[DEBUG] wire - http-outgoing-0 << "[\r][\n]"
[DEBUG] wire - http-outgoing-0 << 
"x[0x9c]e[0x90]Ok[0x2]1[0x10][0xc5][0xef]~[0x8a]%[0xa7][0x16][0x9c][0x98]d[0xfd][0xb3][0xf4][0xb6][0x88]TK{[0x11][0xb][0xde]J6;[0xdd][\r][0xac][0xc9][0xba][0x1b][0xa5]V[0xfc][0xee][0x9d]h[0x91]B[0x8f][0xf3][0xe6][0xf7][0x86]7[0xef]/6[0xb7][0xa3][0xcc]w[0xb6][0xb2][0xee][0x9a]Ep9Q\[0xf0][0x94][\r].[0x83][0x1f][0x86][0xf6]mW"
[DEBUG] headers - http-outgoing-0 << HTTP/1.1 200 OK
[DEBUG] headers - http-outgoing-0 << server: envoy
[DEBUG] headers - http-outgoing-0 << date: Thu, 20 Dec 2018 09:46:40 GMT
[DEBUG] headers - http-outgoing-0 << content-type: application/json
[DEBUG] headers - http-outgoing-0 << content-length: 280
[DEBUG] headers - http-outgoing-0 << content-encoding: deflate
[DEBUG] headers - http-outgoing-0 << access-control-allow-origin: *
[DEBUG] headers - http-outgoing-0 << access-control-allow-credentials: true
[DEBUG] headers - http-outgoing-0 << x-envoy-upstream-service-time: 3
[DEBUG] MainClientExec - Connection can be kept alive indefinitely
[DEBUG] PoolingHttpClientConnectionManager - Connection [id: 0][route: 
{s}->https://httpbin.davecheney.com:443] can be kept alive indefinitely
[DEBUG] DefaultManagedHttpClientConnection - http-outgoing-0: set socket 
timeout to 0
[DEBUG] PoolingHttpClientConnectionManager - Connection released: [id: 
0][route: {s}->https://httpbin.davecheney.com:443][total kept alive: 1; route 
allocated: 1 of 2; total allocated: 1 of 20]
{
  "deflated": true, 
  "headers": {
"Accept-Encoding": "gzip,deflate", 
"Content-Length": "0", 
"Host": "httpbin.davecheney.com", 
"User-Agent": "Apache-HttpClient/4.5.6 (Java/1.8.0_181)", 
"X-Envoy-Expected-Rq-Timeout-Ms": "15000", 
"X-Envoy-Internal": "true", 
"X-Request-Id": "83878b8e-27ba-4d17-be02-23ec2426c321"
  }, 
  "method": "GET", 
  "origin": "10.152.0.3"
}


> 
> 
> 
> 
> }
> 
> 
> 
> 
> -Original Message-
> From: Oleg Kalnichevski  
> Sent: Wednesday, December 19, 2018 7:15 PM
> To: HttpClient User Discussion 
> Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3
> 
> On Wed, 2018-12-19 at 13:39 +, Khare, Aparna wrote:
> > Thank Oleg but if that is the case do I still need to send type
> > cast
> > to GzipDecompressingEntity..without casting to
> > GzipDecompressingEntity Im not getting byte[] some encoding issue
> > with the response content
> > 
> > 
> > 
> > I have seen that when I get the response content as InputStream and
> > convert it to
> > 
> > 
> > 
> > try {
> > 
> > ByteArrayOutputStream outStream = new
> > ByteArrayOutputStream();
> > 
> > int value = inStream.read();
> > 
> > while (value != -1) {
> > 
> >   outStream.write(value);
> > 
> >   value = inStream.read();
> > 
> > }
> > 
> > response = outStream.toByteArray();
> > 
> > 
> > 
> > }
> > 
> > 
> > 
> > It is not sending the byte[] properly..
> > 
> > 
> 
> I am sorry I do not understand.
> 
> Oleg
> 
> 
> > 
> > -Original Message-
> > From: Oleg Kalnichevski 
> > Sent: Wednesday, December 19, 2018 3:47 PM
> > To: HttpClient User Discussion 
> > Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3
> > 
> > 
> > 
> > On Wed, 2

RE: Issue with deflate Content-Encode httpClient 4.1.3

2018-12-20 Thread Khare, Aparna
Hi Oleg,

   https://httpbin.davecheney.com/deflate

I'm trying to do an GET  the response for the above url.

if (response.getEntity() != null) {
InputStream  inStream = response.getEntity().getContent();

if (inStream != null) {
  try {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
int value = inStream.read();
while (value != -1) {
  outStream.write(value);
  value = inStream.read();
}
response = outStream.toByteArray();
  } 
}
Finally this data is required to be parsed on UI where we are using

Both deflated content and gZip data is malformed once the response is returned 
..(Encoding issue)

How can I get this fixed. 

Thanks,
Aparna





}




-Original Message-
From: Oleg Kalnichevski  
Sent: Wednesday, December 19, 2018 7:15 PM
To: HttpClient User Discussion 
Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3

On Wed, 2018-12-19 at 13:39 +, Khare, Aparna wrote:
> Thank Oleg but if that is the case do I still need to send type cast
> to GzipDecompressingEntity..without casting to
> GzipDecompressingEntity Im not getting byte[] some encoding issue
> with the response content
> 
> 
> 
> I have seen that when I get the response content as InputStream and
> convert it to
> 
> 
> 
> try {
> 
> ByteArrayOutputStream outStream = new
> ByteArrayOutputStream();
> 
> int value = inStream.read();
> 
> while (value != -1) {
> 
>   outStream.write(value);
> 
>   value = inStream.read();
> 
> }
> 
> response = outStream.toByteArray();
> 
> 
> 
> }
> 
> 
> 
> It is not sending the byte[] properly..
> 
> 

I am sorry I do not understand.

Oleg


> 
> -Original Message-----
> From: Oleg Kalnichevski 
> Sent: Wednesday, December 19, 2018 3:47 PM
> To: HttpClient User Discussion 
> Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3
> 
> 
> 
> On Wed, 2018-12-19 at 07:41 +, Khare, Aparna wrote:
> 
> > Dear All,
> > 
> > We have some constraints in moving to new httpclient and we are
> > using
> > 4.1.3. Any help is appreciated. gzipContent works but deflated is
> > not
> > working.
> > 
> > if (response.getEntity() != null) {
> >  HttpEntity entity = response.getEntity();
> >   Header contentEncodingHeader =
> > entity.getContentEncoding();
> > 
> >  if (contentEncodingHeader != null) {
> >   HeaderElement[] encodings
> > =contentEncodingHeader.getElements();
> >   for (int i = 0; i < encodings.length; i++) {
> >   if
> > (encodings[i].getName().equalsIgnoreCase("gzip")) {
> >   entity = new GzipDecompressingEntity(entity);
> >   break;
> >   } else
> > if(encodings[i].getName().equalsIgnoreCase("deflate")) {
> >   entity = new
> > DeflateDecompressingEntity(entity);
> >   break;
> >   }
> >   }
> >   }
> > 
> > And we use the below mechanism to set the params in the httpclient
> > ..
> > I have read that I need to disable the compressions. But I could
> > not
> > find how can I set that..
> > 
> 
> 
> 
> HttpClient 4.1 does not support automatic content decompression. You
> do
> 
> not need to disable it.
> 
> 
> 
> Oleg
> 
> 
> 
> 
> 
> > rsClient = new DefaultHttpClient();
> > rsClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
> > TESTCONSOLE);
> > rsClient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS
> > ,
> > false);
> > 
> > Thanks,
> > Aparna
> > 
> 
> 
> 
> 
> 
> -
> 
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org ilto:httpclient-users-unsubscr...@hc.apache.org>
> 
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org<
> mailto:httpclient-users-h...@hc.apache.org>
> 
> 


-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



Re: Issue with deflate Content-Encode httpClient 4.1.3

2018-12-19 Thread Yossi Tamari
On Wed, Dec 19, 2018, 09:41 Khare, Aparna  Dear All,
>
> We have some constraints in moving to new httpclient and we are using
> 4.1.3. Any help is appreciated. gzipContent works but deflated is not
> working.
>
> if (response.getEntity() != null) {
>  HttpEntity entity = response.getEntity();
>   Header contentEncodingHeader = entity.getContentEncoding();
>
>  if (contentEncodingHeader != null) {
>   HeaderElement[] encodings
> =contentEncodingHeader.getElements();
>   for (int i = 0; i < encodings.length; i++) {
>   if (encodings[i].getName().equalsIgnoreCase("gzip")) {
>   entity = new GzipDecompressingEntity(entity);
>   break;
>   } else
> if(encodings[i].getName().equalsIgnoreCase("deflate")) {
>   entity = new DeflateDecompressingEntity(entity);
>   break;
>   }
>   }
>   }
>
> And we use the below mechanism to set the params in the httpclient .. I
> have read that I need to disable the compressions. But I could not find how
> can I set that..
>
> rsClient = new DefaultHttpClient();
> rsClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
> TESTCONSOLE);
> rsClient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
> false);
>
> Thanks,
> Aparna
>
>


Re: Issue with deflate Content-Encode httpClient 4.1.3

2018-12-19 Thread Oleg Kalnichevski
On Wed, 2018-12-19 at 13:39 +, Khare, Aparna wrote:
> Thank Oleg but if that is the case do I still need to send type cast
> to GzipDecompressingEntity..without casting to
> GzipDecompressingEntity Im not getting byte[] some encoding issue
> with the response content
> 
> 
> 
> I have seen that when I get the response content as InputStream and
> convert it to
> 
> 
> 
> try {
> 
> ByteArrayOutputStream outStream = new
> ByteArrayOutputStream();
> 
> int value = inStream.read();
> 
> while (value != -1) {
> 
>   outStream.write(value);
> 
>   value = inStream.read();
> 
> }
> 
> response = outStream.toByteArray();
> 
> 
> 
> }
> 
> 
> 
> It is not sending the byte[] properly..
> 
> 

I am sorry I do not understand.

Oleg


> 
> -Original Message-----
> From: Oleg Kalnichevski 
> Sent: Wednesday, December 19, 2018 3:47 PM
> To: HttpClient User Discussion 
> Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3
> 
> 
> 
> On Wed, 2018-12-19 at 07:41 +, Khare, Aparna wrote:
> 
> > Dear All,
> > 
> > We have some constraints in moving to new httpclient and we are
> > using
> > 4.1.3. Any help is appreciated. gzipContent works but deflated is
> > not
> > working.
> > 
> > if (response.getEntity() != null) {
> >  HttpEntity entity = response.getEntity();
> >   Header contentEncodingHeader =
> > entity.getContentEncoding();
> > 
> >  if (contentEncodingHeader != null) {
> >   HeaderElement[] encodings
> > =contentEncodingHeader.getElements();
> >   for (int i = 0; i < encodings.length; i++) {
> >   if
> > (encodings[i].getName().equalsIgnoreCase("gzip")) {
> >   entity = new GzipDecompressingEntity(entity);
> >   break;
> >   } else
> > if(encodings[i].getName().equalsIgnoreCase("deflate")) {
> >   entity = new
> > DeflateDecompressingEntity(entity);
> >   break;
> >   }
> >   }
> >   }
> > 
> > And we use the below mechanism to set the params in the httpclient
> > ..
> > I have read that I need to disable the compressions. But I could
> > not
> > find how can I set that..
> > 
> 
> 
> 
> HttpClient 4.1 does not support automatic content decompression. You
> do
> 
> not need to disable it.
> 
> 
> 
> Oleg
> 
> 
> 
> 
> 
> > rsClient = new DefaultHttpClient();
> > rsClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
> > TESTCONSOLE);
> > rsClient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS
> > ,
> > false);
> > 
> > Thanks,
> > Aparna
> > 
> 
> 
> 
> 
> 
> -
> 
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org ilto:httpclient-users-unsubscr...@hc.apache.org>
> 
> For additional commands, e-mail: httpclient-users-h...@hc.apache.org<
> mailto:httpclient-users-h...@hc.apache.org>
> 
> 


-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org



RE: Issue with deflate Content-Encode httpClient 4.1.3

2018-12-19 Thread Khare, Aparna
Thank Oleg but if that is the case do I still need to send type cast to 
GzipDecompressingEntity..without casting to GzipDecompressingEntity Im not 
getting byte[] some encoding issue with the response content



I have seen that when I get the response content as InputStream and convert it 
to



try {

ByteArrayOutputStream outStream = new ByteArrayOutputStream();

int value = inStream.read();

while (value != -1) {

  outStream.write(value);

  value = inStream.read();

}

response = outStream.toByteArray();



}



It is not sending the byte[] properly..



-Original Message-
From: Oleg Kalnichevski 
Sent: Wednesday, December 19, 2018 3:47 PM
To: HttpClient User Discussion 
Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3



On Wed, 2018-12-19 at 07:41 +, Khare, Aparna wrote:

> Dear All,

>

> We have some constraints in moving to new httpclient and we are using

> 4.1.3. Any help is appreciated. gzipContent works but deflated is not

> working.

>

> if (response.getEntity() != null) {

>  HttpEntity entity = response.getEntity();

>   Header contentEncodingHeader = entity.getContentEncoding();

>

>  if (contentEncodingHeader != null) {

>   HeaderElement[] encodings

> =contentEncodingHeader.getElements();

>   for (int i = 0; i < encodings.length; i++) {

>   if

> (encodings[i].getName().equalsIgnoreCase("gzip")) {

>   entity = new GzipDecompressingEntity(entity);

>   break;

>   } else

> if(encodings[i].getName().equalsIgnoreCase("deflate")) {

>   entity = new

> DeflateDecompressingEntity(entity);

>   break;

>   }

>   }

>   }

>

> And we use the below mechanism to set the params in the httpclient ..

> I have read that I need to disable the compressions. But I could not

> find how can I set that..

>



HttpClient 4.1 does not support automatic content decompression. You do

not need to disable it.



Oleg





> rsClient = new DefaultHttpClient();

> rsClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,

> TESTCONSOLE);

> rsClient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,

> false);

>

> Thanks,

> Aparna

>





-

To unsubscribe, e-mail: 
httpclient-users-unsubscr...@hc.apache.org<mailto:httpclient-users-unsubscr...@hc.apache.org>

For additional commands, e-mail: 
httpclient-users-h...@hc.apache.org<mailto:httpclient-users-h...@hc.apache.org>




Re: Issue with deflate Content-Encode httpClient 4.1.3

2018-12-19 Thread Oleg Kalnichevski
On Wed, 2018-12-19 at 07:41 +, Khare, Aparna wrote:
> Dear All,
> 
> We have some constraints in moving to new httpclient and we are using
> 4.1.3. Any help is appreciated. gzipContent works but deflated is not
> working.
> 
> if (response.getEntity() != null) {
>  HttpEntity entity = response.getEntity();
>   Header contentEncodingHeader = entity.getContentEncoding();
> 
>  if (contentEncodingHeader != null) {
>   HeaderElement[] encodings
> =contentEncodingHeader.getElements();
>   for (int i = 0; i < encodings.length; i++) {
>   if
> (encodings[i].getName().equalsIgnoreCase("gzip")) {
>   entity = new GzipDecompressingEntity(entity);
>   break;
>   } else
> if(encodings[i].getName().equalsIgnoreCase("deflate")) {
>   entity = new
> DeflateDecompressingEntity(entity);
>   break;
>   }
>   }
>   }
> 
> And we use the below mechanism to set the params in the httpclient ..
> I have read that I need to disable the compressions. But I could not
> find how can I set that..
> 

HttpClient 4.1 does not support automatic content decompression. You do
not need to disable it.

Oleg


> rsClient = new DefaultHttpClient();
> rsClient.getParams().setParameter(CoreProtocolPNames.USER_AGENT,
> TESTCONSOLE);
> rsClient.getParams().setParameter(ClientPNames.HANDLE_REDIRECTS,
> false);
> 
> Thanks,
> Aparna
> 


-
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org