1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00
httparty/features/handles_compressed_responses.feature
Marc Slemko 2b5fc1917d Support gzip/deflate transfer encoding when explicit headers are set.
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
4797c7696d because it was not properly
testing what it claimed to and the code it was trying to test was
removed in 6f6bf6b726 anyway.
2019-11-28 15:23:35 -08:00

40 lines
1.9 KiB
Gherkin

Feature: Handles Compressed Responses
In order to save bandwidth
As a developer
I want to leverage Net::Http's built in transparent support for gzip and deflate content encoding
Scenario: Supports deflate encoding
Given a remote deflate service
And the response from the service has a body of '<h1>Some HTML</h1>'
And that service is accessed at the path '/deflate_service.html'
When I call HTTParty#get with '/deflate_service.html'
Then the return value should match '<h1>Some HTML</h1>'
And it should return a response without a content-encoding
Scenario: Supports gzip encoding
Given a remote gzip service
And the response from the service has a body of '<h1>Some HTML</h1>'
And that service is accessed at the path '/gzip_service.html'
When I call HTTParty#get with '/gzip_service.html'
Then the return value should match '<h1>Some HTML</h1>'
And it should return a response without a content-encoding
Scenario: Supports gzip encoding with explicit header set
Given a remote gzip service
And the response from the service has a body of '<h1>Some HTML</h1>'
And that service is accessed at the path '/gzip_service.html'
When I set my HTTParty header 'User-Agent' to value 'Party'
And I call HTTParty#get with '/gzip_service.html'
Then the return value should match '<h1>Some HTML</h1>'
And it should return a response without a content-encoding
Scenario: Supports deflate encoding with explicit header set
Given a remote deflate service
And the response from the service has a body of '<h1>Some HTML</h1>'
And that service is accessed at the path '/deflate_service.html'
When I set my HTTParty header 'User-Agent' to value 'Party'
And I call HTTParty#get with '/deflate_service.html'
Then the return value should match '<h1>Some HTML</h1>'
And it should return a response without a content-encoding