Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

un-gzip based on content-encoding #81

Open
matthusby opened this issue Oct 10, 2015 · 3 comments

Comments

Projects
None yet
4 participants
@matthusby
Copy link
Contributor

commented Oct 10, 2015

If the response has Content-Encoding: gzip the body should be automatically unzipped.

@edgurgel

This comment has been minimized.

Copy link
Owner

commented Nov 2, 2015

This will be done upstream by hackney: benoitc/hackney#155

We can keep this issue open until it's available.

@edgurgel edgurgel added the enhancement label Nov 2, 2015

@marvelm

This comment has been minimized.

Copy link

commented May 18, 2016

For anyone looking for a stopgap until this feature is implemented:

res = HTTPoison.get(url)
gzipped = Enum.any?(res.headers, fn (kv) ->
  case kv do
    {"Content-Encoding", "gzip"} -> true
    {"Content-Encoding", "x-gzip"} -> true
    _ -> false
  end
end)

# body is an Elixir string
body = if gzipped do
    :zlib.gunzip(res.body)
  else
    res.body
  end
@jaimeiniesta

This comment has been minimized.

Copy link

commented May 11, 2017

@marvelm works like a charm thanks - but some servers return { "Content-Encoding", "x-gzip" } instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.