Reputation: 79
I am using apache httpclient 4.2 to send Multipart HTTP PUT request. The client has to upload large size binary data of the order of 500 MB. Hence compression is required. I wish to compress the whole Multipart HTTP request and inform the server through header Content-Encoding: gzip. I control the server as well as client code.
Note: I am aware of the approach where I can selectively compress the large size binary data & not the whole request but for now I am ruling out that approach.
The httpclient's HttpRequestInterceptor class doesn't provide a handle to the request input stream or an entity to compress the request.
I have searched on the web & found few related links(below) but none of them works 1. http://old.nabble.com/compressing-multipart-request-from-custom-client-tt27804438.html#a27811350 2. http://hc.apache.org/httpcomponents-client-ga/tutorial/html/fundamentals.html#protocol_interceptors - This link says that "Protocol interceptors can also manipulate content entities enclosed with messages - transparent content compression / decompression being a good example." but don't know how to get the desired functionality.
Please give me some direction, if possible some sample code.
Upvotes: 2
Views: 1451
Reputation: 79
I was finally able to solve this requirement by
Adding the compressed binary part to the HTTP request
ByteArrayBody binaryData = new ByteArrayBody(compressedData, "binary/octet-stream", "N/A"); binaryParts.add(binaryData); reqEntity.addPart("uniqueId", binaryPart);
Upvotes: 2