← 返回 stripe 的题目列表Bug Bash: Fix 301 Redirect Handling for Streaming/Binary POST Requests in a Custom HTTP Client
类型:online_judge
Task: Fix a timeout bug in a custom HTTP client when handling 301 redirects (file stream + binary POST bodies)
You are given a repository that implements a custom HTTP request/client library, including automatic 301 redirect handling.
Two 301 redirect-related test cases are failing:
A POST request with a file stream body fails when a 301 redirect occurs
A POST request with a binary/bytes body fails when a 301 redirect occurs
Observed failure:
The test times out during a post step
There is no straightforward stack trace pointing to the root cause (deep call stack, little code comments)
A plausible suspicion is that the bug lives in a low-level helper responsible for moving/reading a cursor/reader, and that redirect retry causes the body reader to be in an invalid state, possibly leading to a loop or a never-ending read, hence the timeout.
What you need to do
Run the tests and reproduce the two failures.
Identify the root cause of the timeout (focus on how request bodies are handled after a 301 redirect).
Patch the library so that both tests pass without breaking other tests.
Behaviors you are expected to infer from the repo
How the library triggers a follow-up request after receiving a 301
The policy for POST requests on a 301 (whether to keep method, whether to resend body, etc.)
Whether stream/bytes bodies can be correctly replayed/rewound/reset after redirect
Whether a cursor/reader helper advances incorrectly (e.g., not reset, wrong offset, reading past EOF, repeated seek loops)
Deliverables
A patch that makes all tests pass.
A brief explanation: root cause, where you fixed it, and why it eliminates the timeout.