# How to read a gzipped HTTP response?

**URL:** https://discourse.julialang.org/t/how-to-read-a-gzipped-http-response/24854
**Category:** General Usage
**Created:** [June 2, 2019, 3:26pm UTC](https://discourse.julialang.org/t/how-to-read-a-gzipped-http-response/24854 "2019-06-02T15:26:16Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![anon67531922](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon67531922](https://discourse.julialang.org/u/anon67531922)
#### Post date: [June 2, 2019, 3:26pm UTC](https://discourse.julialang.org/t/how-to-read-a-gzipped-http-response/24854/1 "2019-06-02T15:26:16Z")

</div>

Hi,

I’m working with a third-party API and apparently `Accept-Encoding: identity` is not possible, so I am receiving a gzipped response body whether I like it or not.

I’ve been looking at [TranscodingStreams.jl](https://github.com/bicycle1885/TranscodingStreams.jl) for a while now and still not any closer to figuring this out so could use a nudge in the right direction. Can someone help me decode a gzipped HTTP response body? 🙏

PS: I’ve also seen Gzip.jl, but a little hesitant to use it since it doesn’t seem to be maintained. Please correct me if I’m wrong. Maybe it is solid and doesn’t need maintenance? 😅

---

<div class="post-metadata">

### Author: ![anon67531922](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@anon67531922](https://discourse.julialang.org/u/anon67531922)
#### Post date: [June 2, 2019, 4:05pm UTC](https://discourse.julialang.org/t/how-to-read-a-gzipped-http-response/24854/2 "2019-06-02T16:05:08Z")

</div>

As usual, the answer is right there is the docs 🙂

[https://bicycle1885.github.io/TranscodingStreams.jl/stable/examples/#Transcode-data-in-one-shot-1](https://bicycle1885.github.io/TranscodingStreams.jl/stable/examples/#Transcode-data-in-one-shot-1)

```julia
decompressed = transcode(GzipDecompressor, r.body)

```

---

<div class="post-metadata">

### Author: ![kevin.squire](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevin.squire/32/62_2.png) [@kevin.squire](https://discourse.julialang.org/u/kevin.squire)
#### Post date: [June 3, 2019, 2:18pm UTC](https://discourse.julialang.org/t/how-to-read-a-gzipped-http-response/24854/3 "2019-06-03T14:18:12Z")

</div>

> [@anon67531922](#):
>
> PS: I’ve also seen Gzip.jl, but a little hesitant to use it since it doesn’t seem to be maintained. Please correct me if I’m wrong. Maybe it is solid and doesn’t need maintenance?

GZip.jl is a low-level wrapper around the gzip functionality in libz. Because of this, there’s not much to maintain–it should generally work fine, but won’t do anything fancy and might not give you the fastest results (you would have to test different buffer sizes).

TranscodingStreams.jl (and the underlying [CodecZlib.jl](https://github.com/bicycle1885/CodecZlib.jl)) are a bit more modern and flexible, and should be faster (by default, at least).

Cheers,  
Kevin

---

<div class="post-metadata">

### Author: ![js135005](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/js135005/32/8219_2.png) [@js135005](https://discourse.julialang.org/u/js135005)
#### Post date: [June 3, 2019, 3:29pm UTC](https://discourse.julialang.org/t/how-to-read-a-gzipped-http-response/24854/4 "2019-06-03T15:29:08Z")

</div>

I use TranscodingStreams and CodecZlib in production. I have found it to be much faster than GZip.

---

<div class="post-metadata">

### Author: ![bicycle1885](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bicycle1885/32/107_2.png) [@bicycle1885](https://discourse.julialang.org/u/bicycle1885)
#### Post date: [June 3, 2019, 4:31pm UTC](https://discourse.julialang.org/t/how-to-read-a-gzipped-http-response/24854/5 "2019-06-03T16:31:56Z")

</div>

Just a note: CodecZlib.jl is still far from optimal because it uses binaries compiled by BinaryBuilder.jl. I found that those are much slower (~2-3 times) than those of systems or compiled on the target architecture. I believe Elliot will resolve or mitigate the problem in the near future.
