I have a file let's call it "xyz.dat" that I want to send, so on the
client side I'm doing this:
Client c = Client.create();
c.addFilter(new HTTPBasicAuthFilter("xxxx", "xxxx"));
WebResource r = c.resource(uri);
ClientResponse response = r.accept("application/somethingf")
.post(ClientResponse.class, new File(sourceFile));
Pretty cool. Now I want to see if it can send it with content encoding of gzip:
c.addFilter(new GZIPContentEncodingFilter(true));
Seems to do something, but it's not good:
Exception in thread "main"
com.sun.jersey.api.client.ClientHandlerException: java.io.IOException:
insufficient data written
Do I need to do something else, like explicitly tell it to set the
Content-Encoding header prior to making the request?
Related question... does my Resource need to be aware of this at all?
My resource method is:
@POST
@Consumes("application/something")
public Response receiveFile(inputStream stream) {
// do something with the stream
}
for example, do I need to check Content-Encoding in my resource
method, and do something like stream = new GZIPInputStream(stream); ?
Jersey handles so many of these things transparently that I thought
this would be one of them.
--C