Skip to content

Gzip will compress the compressed body again #47

Open
@LawyZheng

Description

@LawyZheng

Gzip will compress the compressed body again when I use third-party handlers to handle gin context,
like httputil.ReverseProxy, promhttp.

It seems if the target HTTP server returns a gzip-compressed body, the middleware will compress it again,
which could result in the client can't decompress the response correctly.

For example, Prometheus can't scrape the target response correctly or some responses will be garbled, due to the double compression.

Though I can solve this problem by setting the gzip.WithExcludedPaths or other ExcludedOptions, I don't think it is the best way. Because sometimes we want to solve this problem more wisely and elegantly, rather than coding the ExcludedOptions hardly.

I also tried to fix this problem by myself. And past all default unit tests.

Am I welcomed to make a pr?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions