Skip to content

Content-Length header set to 0 in HEAD requests #659

Description

@johanpoirier

Hi,

I g-have a problem with HEAD requests : mitmproxy override Content-Length header and set it to 0.

Without mitmproxy:

HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: max-age=86400
Connection: keep-alive
Content-Length: 1488324
Content-Type: application/epub+zip
Date: Mon, 29 Jun 2015 09:20:54 GMT
ETag: "559103d3-16b5c4"
Expires: Tue, 30 Jun 2015 09:20:54 GMT
Last-Modified: Mon, 29 Jun 2015 08:37:39 GMT
Server: nginx

With mitmproxy:

Accept-Ranges: bytes
Cache-Control: max-age=86400
Connection: keep-alive
Content-Length: 0
Content-Type: application/epub+zip
Date: Mon, 29 Jun 2015 09:48:54 GMT
Etag: "559103d3-16b5c4"
Expires: Tue, 30 Jun 2015 09:48:54 GMT
Last-Modified: Mon, 29 Jun 2015 08:37:39 GMT
Server: nginx

I looked in the code and I saw that the Content-Length is computed from the length of the body of the request. Or HEAD requests have no body but can have a Content-Length > 0.

I don't know how to fix the bug but if anyone has a solution, I would be happy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions