Skip to content

gh-49288: Reset file-like POST body on HTTP auth retry#153726

Open
orsenthil wants to merge 4 commits into
python:mainfrom
orsenthil:orsenthil/49288
Open

gh-49288: Reset file-like POST body on HTTP auth retry#153726
orsenthil wants to merge 4 commits into
python:mainfrom
orsenthil:orsenthil/49288

Conversation

@orsenthil

@orsenthil orsenthil commented Jul 15, 2026

Copy link
Copy Markdown
Member

Fix long-standing bug where HTTP Basic/Digest auth retries send an empty POST body when Request.data is a consumed file-like object (e.g. mmap.mmap, open file, BytesIO).

Fixes gh-49288.

Wrap seekable file-like Request.data in a re-iterator before Basic and
Digest authentication retries so the POST body is resent after a 401.
Non-seekable streams raise ValueError instead of sending an empty body.
@read-the-docs-community

read-the-docs-community Bot commented Jul 15, 2026

Copy link
Copy Markdown

Documentation build overview

📚 cpython-previews | 🛠️ Build #33602220 | 📁 Comparing 945a7ce against main (1b3914a)

  🔍 Preview build  

2 files changed
± library/urllib.request.html
± whatsnew/changelog.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

urrlib2/httplib doesn't reset file position between requests

1 participant