Skip to content

Respect file cursor positions when calculating raw content length - #1214

Merged
Kludex merged 9 commits into
mainfrom
respect-raw-content-file-offsets
Sep 22, 2026
Merged

Kludex merged 9 commits into
mainfrom
respect-raw-content-file-offsets

Conversation

@Kludex

@Kludex Kludex commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Calculate Content-Length for content=fileobj from the current cursor, using zero at or past EOF and chunked transfer when the length cannot be determined. Use logical seek/tell measurements so transformed streams do not mix compressed file sizes with decompressed offsets; this can scan compressed streams during length detection. Leave multipart rewind behavior unchanged.

Add five focused public-API regression cases: a partial file, EOF, past EOF, a gzip stream, and a non-seekable pipe. Keep the existing BytesIO test and the multipart length assertion.

Validation on Python 3.15: 1,740 tests passed, 1 skipped, and 5 network tests excluded. Ruff and mypy pass; all changed files have 100% coverage.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-17T07:57:30.805512Z d6a9a5d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codspeed

codspeed Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 17 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing respect-raw-content-file-offsets (c1cbceb) with main (f295185)

Open in CodSpeed

Footnotes

  1. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment thread src/httpx2/httpx2/_content.py Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/httpx2/httpx2/_content.py Resolved
@Kludex
Kludex merged commit df9783d into main Sep 22, 2026
19 checks passed
@Kludex
Kludex deleted the respect-raw-content-file-offsets branch September 22, 2026 09:45
@Kludex Kludex mentioned this pull request Sep 22, 2026
2 tasks done
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