Support gzip/deflate transfer encoding when explicit headers are set. #678
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
httparty relies on Net::HTTP's built in transparent support for gzip and deflate
transfer encoding, however that did not work if you specified your own explicit headers
because calling Net::HTTPHeader#initialize_http_header overwrites the work done in
Net::HTTPGenericRequest#initialize to set the default User-Agent, Accept,
and Accept-Encoding. This also removes the need to duplicate the logic in
Net::HTTP around not decoding the response if the caller has explicitly set
the Accept-Encoding for their own purposes.
This does introduce a slight incompatible change in behavior where
previously specifying any custom headers would omit the default headers,
while with the new behavior you can override the values however
can't omit them entirely.
While I'm here, also remove the test for HEAD requests added in
4797c76 because it was not properly
testing what it claimed to and the code it was trying to test was
removed in 6f6bf6b anyway.