When I attempt to download a pdf file from a URL with AFNetworking, the size of the saved file is about half of what I expected. When I make the same request using curl/standard browser tool, the file size is correct.
How do decompress the file on the fly so it is readable? Or is AFNetworking automatically compressing the file that it shouldn't?
The following request header is set by default by AFNetworking's client class:
"Accept-Encoding" = gzip;
"Accept" = application/json";
Here's how I'm fetching the file:
AFHTTPClient *client; // already instantiated & configured
NSURLRequest *request = [client requestWithMethod:@"GET" path:requestPath parameters:parameters];
AFHTTPRequestOperation *operation = [client HTTPRequestOperationWithRequest:request success:success failure:failure];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:localFilePath append:NO];
[self enqueueHTTPRequestOperation:operation];
Later, when I check the file size via NSFileManager and via external tool, the size is 1/2 of what I'm expecting.
When I issue the same request via a HTTP browser client, I don't see anything in the response headers to indicate that returned content is compressed.
Response Headers sent by server (checked via HTTP browser extension tool):
Transfer-Encoding: chunked
Status: 200 OK
Content-Transfer-Encoding: binary
Content-Disposition: inline; filename="document_sample.pdf"
Connection: keep-alive
Content-Type: application/pdf
Cache-Control: private
How does one download the file so it's preserved as expected?