mattn / go-mastodon

mastodon client for golang
MIT License
604 stars 88 forks source link

Add support for gzipped requests in doAPI #173

Closed Saiv46 closed 1 year ago

Saiv46 commented 1 year ago

I was been asked by one guy to create issue here, but instead I made a PR

Please add support compressed http request. This feature helps working with mastodon API in low-bandwidth networks. Just add in header req.Header.Set("accept-encoding", "gzip"). And decoding data:

        var reader io.ReadCloser
        switch resp.Header.Get("Content-Encoding") {
        case "gzip":
                reader, err = gzip.NewReader(resp.Body)
                defer reader.Close()
        default:
                reader = resp.Body
        }
        return json.NewDecoder(reader).Decode(&res)

Thanks.

Saiv46 commented 1 year ago

@mattn Do I need to add Deflate support to get this merged?