Skip to content

Instantly share code, notes, and snippets.

@fernandes
Last active February 24, 2019 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fernandes/96c0835d67e305f88b10d7c19c308e98 to your computer and use it in GitHub Desktop.
Save fernandes/96c0835d67e305f88b10d7c19c308e98 to your computer and use it in GitHub Desktop.
Crystal HTTP::Client not processing gzip response
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