On Thu, 2018-12-20 at 08:20 +0000, 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: Apache-HttpClient/4.5.6
(Java/1.8.0_181)
[DEBUG] headers - http-outgoing-0 >> Accept-Encoding: gzip,deflate
[DEBUG] wire - http-outgoing-0 >> "GET /deflate HTTP/1.1[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "Host: httpbin.davecheney.com[\r][\n]"
[DEBUG] wire - http-outgoing-0 >> "Connection: Keep-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]<H[0x12]V[0xe2]g[0xa3][0x3][0x96][0xec])[0x9][0xdd][0x1][0x87]I[0x14]k[0xd4]%v=ig[0x1a]I[0xc8][0x8d][0xc1]6[0xc0][0xc2][0x19]_ZW[0xd1][0x82]U[0xdf][0xb6][0x1d][0xfe][0xba][0xd9][0xd5]F[0xdc][0xdc][0xbb][0x80].[0xc0]+[0xba]*[0xd4][0x11][0x13][0xf7][0xdd][0xd2][0xf7]!*u[0x8]ma[0x1d]/[0xf5][0x11]M[0x8d][0xe]O[0xdc][0xf8][0xdd][0x1d]{[0xef][0xb1][0x83][0xbc][0xa2]+[0x11][0xce][M[0xc],[0xc9]3o,[0x89][0xa3]1[0x9f][0xf0]i[0xf2][0xf0][0xa2][0x8f]z$y[0xc6][0xc5][0x87][0xcc][0xe4][0xe3][0xdd][0xbe][0xa5][0x90]G[0x82][0xc5]W[0x8b][0x86][0xfe][0x82][0xf5][0x1e]6v[0x87][0xfe][0x10][0xe0]-~[0xc4][0xe4]D[0x8][0xf1][0x8f]_Q[0xf0][0xce][0xe9]&[0x12][0xb1][0x88]?[0xc0][0x1a][0xf7][0x7][0xec][0x3][0xac]bI,K[0xb3]YVd[0x8]jVh[0x18][0x97]r[0x6][0x5][\n]"
[DEBUG] wire - http-outgoing-0 <<
"[0x5]*E[0xa3][0xc6]jjR%[0x19]Y/[0xb7]*w[0x18]j5>/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 <[email protected]>
> Sent: Wednesday, December 19, 2018 7:15 PM
> To: HttpClient User Discussion <[email protected]>
> Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3
>
> On Wed, 2018-12-19 at 13:39 +0000, 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 <[email protected]>
> > Sent: Wednesday, December 19, 2018 3:47 PM
> > To: HttpClient User Discussion <[email protected]>
> > Subject: Re: Issue with deflate Content-Encode httpClient 4.1.3
> >
> >
> >
> > On Wed, 2018-12-19 at 07:41 +0000, 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_REDIREC
> > > TS
> > > ,
> > > false);
> > >
> > > Thanks,
> > > Aparna
> > >
> >
> >
> >
> >
> >
> > -----------------------------------------------------------------
> > ----
> >
> > To unsubscribe, e-mail: [email protected]<
> > ma
> > ilto:[email protected]>
> >
> > For additional commands, e-mail:
> > [email protected]<
> > mailto:[email protected]>
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]