Last active
February 24, 2019 00:52
-
-
Save fernandes/96c0835d67e305f88b10d7c19c308e98 to your computer and use it in GitHub Desktop.
Crystal HTTP::Client not processing gzip response
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "http/client" | |
require "gzip" | |
# With no Accept-Encoding, works | |
uri = URI.parse("https://www.google.com") | |
client = HTTP::Client.new uri | |
response = client.get "/" | |
puts response.body | |
# With Accept-Encoding=gzip, prints binary | |
headers = HTTP::Headers{"Accept-Encoding" => "gzip, deflate"} | |
uri = URI.parse("https://www.google.com") | |
client = HTTP::Client.new uri | |
client.compress = true | |
response = client.get "/", headers: headers | |
puts response.body |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment