hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ijabz <ij...@fastmail.fm>
Subject Problems trying to gziip a post
Date Wed, 11 May 2011 09:28:17 GMT

I need to send a HTTPPost with body gzipped, the server accepts non gzipped
data also but would prefer it gzipped, so Im trying to convert some existing
workign code to use gzip
The data is currently set with 

httpMethod.setEntity(new UrlEncodedFormEntity(nameValuePairs));
Ive tried sublclassing  HttpEntityWrapper

static class GzipWrapper extends HttpEntityWrapper
    {
        public GzipWrapper(HttpEntity wrapped)
        {
            super(wrapped);
        }

        public void writeTo(OutputStream outstream)
             throws IOException
        {
            GZIPOutputStream gzip = new GZIPOutputStream(outstream);
            super.writeTo(gzip);
        }
    }

and added 

if (!httpMethod.containsHeader("Accept-Encoding"))
            {
                httpMethod.addHeader("Accept-Encoding", "gzip");
            }

but now my request just time outs I think there must be something wrong with
my GZIpWrapper but Im not sure what.

On another note I looked at the
http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client/ClientGZipContentCompression.java.
example. Aside from the fact that I dont like interceptors because it is
difficult to follow program flow it doesnt make sense to me because the
request header is set to tell the server to accept gzip data but nowhere
does it actually gzip encode any data, it only unzips the response.
-- 
View this message in context: http://old.nabble.com/Problems-trying-to-gziip-a-post-tp31592672p31592672.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Mime
View raw message