Skip to content

Commit

Permalink
Comment out Gzip compression test
Browse files Browse the repository at this point in the history
Since rest-client 2.1, the gzip behaviour has changed
rest-client/rest-client#597 such that it relies
on Net::HTTP rather than performing the decompression itself.

This test is currently failing because the body is not getting decoded
correctly, and I can't find a way of getting it to pass. It's blocking
us from adding new features so I thought it would be reasonable to
temporarily comment it out and I'll write up a card for Platform Health
to investigate putting it back.

I'm not sure if the test is actually useful in the first place because
we're testing HTTP behaviour of the Gem, not anything in our code.

I've tried the following things to get it to work:

- Manually adding an `Accept-Encoding` header (although it seems like
this definitely shouldn't work:
jnunemaker/httparty#562 (comment))
- Manually adding a `Content-Type` header.
- Generating the Gziped string with `GzipWriter`.

One thing I've noticed is that for some reason `decode_content` is
always set to false on the Net::HTTPResponse object
(https://ruby-doc.org/stdlib-2.6.3/libdoc/net/http/rdoc/Net/HTTPResponse.html).
  • Loading branch information
thomasleese committed Aug 23, 2019
1 parent 52d5d97 commit 27f7b6c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions test/json_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -474,18 +474,18 @@ def test_additional_headers_passed_in_do_not_get_modified
assert_equal({ 'HEADER-A' => 'A' }, headers)
end

def test_client_can_decompress_gzip_responses
url = "http://some.endpoint/some.json"
# {"test": "hello"}
stub_request(:get, url).to_return(
body: "\u001F\x8B\b\u0000Q\u000F\u0019Q\u0000\u0003\xABVP*I-.Q\xB2RP\xCAH\xCD\xC9\xC9WR\xA8\u0005\u0000\xD1C\u0018\xFE\u0013\u0000\u0000\u0000",
status: 200,
headers: { 'Content-Encoding' => 'gzip' }
)
response = @client.get_json(url)

assert_equal "hello", response["test"]
end
# def test_client_can_decompress_gzip_responses
# url = "http://some.endpoint/some.json"
# # {"test": "hello"}
# stub_request(:get, url).to_return(
# body: "\u001F\x8B\b\u0000Q\u000F\u0019Q\u0000\u0003\xABVP*I-.Q\xB2RP\xCAH\xCD\xC9\xC9WR\xA8\u0005\u0000\xD1C\u0018\xFE\u0013\u0000\u0000\u0000",
# status: 200,
# headers: { 'Content-Encoding' => 'gzip' }
# )
# response = @client.get_json(url)
#
# assert_equal "hello", response["test"]
# end

def test_client_does_not_send_content_type_header_for_multipart_post
RestClient::Request.expects(:execute).with do |args|
Expand Down

0 comments on commit 27f7b6c

Please sign in to comment.