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 <ol...@apache.org> 
Sent: Wednesday, December 19, 2018 7:15 PM
To: HttpClient User Discussion <httpclient-users@hc.apache.org>
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 <ol...@apache.org>
> Sent: Wednesday, December 19, 2018 3:47 PM
> To: HttpClient User Discussion <httpclient-users@hc.apache.org>
> 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_REDIRECTS
> > ,
> > false);
> > 
> > Thanks,
> > Aparna
> > 
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 
> To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org<ma
> 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

Reply via email to