Skip to content

GZIP request body encoding falling back to raw #4735

@cliplicht

Description

@cliplicht

Problem Description

GZIP requests are not decoded correctly.
This only occurs in the request and not in the response. In the response I see the body as uncompromised gzip but not in the request.

I created a own content view to test the gzip decompression:

from typing import Optional
from mitmproxy import contentviews, flow
from mitmproxy import http
import gzip


class ViewGZIPCase(contentviews.View):
    name = "GZIP"

    def __call__(self, data, **metadata) -> contentviews.TViewResult:
        return "gzip", contentviews.format_text(gzip.decompress(data))

    def render_priority(
            self,
            data: bytes,
            *,
            content_type: Optional[str] = None,
            flow: Optional[flow.Flow] = None,
            http_message: Optional[http.Message] = None,
            **unknown_metadata,
    ) -> float:

        if http_message.headers["content-encoding"] == "GZIP":
            return 1

        else:
            return 0


view = ViewGZIPCase()


def load(l):
    contentviews.add(view)


def done():
    contentviews.remove(view)
request

with selected self-made view
Screenshot 2021-08-05 at 16 42 57

without any special view
Screenshot 2021-08-05 at 16 42 42

response

Mitmproxy standalone decompression and json parsing in the response but why not in the request?
Screenshot 2021-08-05 at 16 47 55

Steps to reproduce the behavior:

  1. start Mitmproxy
  2. wait for requests ( iPhone 12 as client is connected)
  3. open the request

System Information

Mitmproxy: 7.0.2
Python: 3.9.6
OpenSSL: OpenSSL 1.1.1k 25 Mar 2021
Platform: macOS-11.5.1-x86_64-i386-64bit

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions