Skip to content

Report decoded response content sizes in HAR exports - #8534

Closed
hakarrr wants to merge 6 commits into
mitmproxy:mainfrom
hakarrr:fix/har-decoded-content-size
Closed

hakarrr wants to merge 6 commits into
mitmproxy:mainfrom
hakarrr:fix/har-decoded-content-size

Conversation

@hakarrr

@hakarrr hakarrr commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Description

HAR 1.2 defines response.content.size as the decoded content length and response.bodySize as the received encoded body length. The exporter currently assigns the encoded length to both, even though it already computes the decoded length for content.compression.

Use the decoded length for content.size, keeping bodySize, compression, and exported content unchanged. For a 1,200-byte text body compressed to 46 bytes, this changes content.size from 46 to 1,200 while retaining bodySize: 46 and compression: 1154.

  • Add regressions for gzip-compressed text and binary responses.
  • Correct exactly three content-size values in the existing HAR fixture; the editor also adds its final newline.
  • Preserve the existing fallback for malformed compressed bodies.

Specification: https://w3c.github.io/web-performance/specs/HAR/Overview.html#content

Validation against main 1d5d831c:

  • Two new cases fail before the fix and pass after it.
  • HAR addon: 24 passed.
  • Addons suite: 541 passed, 1 skipped.
  • Core tests excluding addons and proxy: 1,012 passed, 1 skipped.
  • uv run --no-sync tox -e lint and changed-file Ruff formatting checks pass.

Tests use the existing development environment with --no-sync; the newest main dependency lock was not reinstalled for the pytest runs.

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

hakarrr and others added 6 commits October 26, 2026 03:47
Use decoded body length for content.size while retaining raw bytes for bodySize and the existing compression calculation.

Co-authored-by: generaltony007 <[email protected]>
Check decoded size, encoded bodySize, and bytes saved for gzip text and binary responses.

Co-authored-by: generaltony007 <[email protected]>
Update exactly three compressed response content.size fields; bodySize, text and compression are unchanged.

Co-authored-by: generaltony007 <[email protected]>
Note the HAR export size correction.

Co-authored-by: generaltony007 <[email protected]>
@hakarrr

hakarrr commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

Could a maintainer give the HAR decoded-response-size fix a human review and advise on the next step? Please let me know if changes are needed or if you'd prefer this PR closed. Thanks.

@hakarrr hakarrr closed this Nov 17, 2026
@hakarrr
hakarrr deleted the fix/har-decoded-content-size branch November 25, 2026 06:21
@hakarrr
hakarrr restored the fix/har-decoded-content-size branch November 25, 2026 06:22
@hakarrr
hakarrr deleted the fix/har-decoded-content-size branch November 25, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant