Fix #1972: bypass body-reading for HEAD requests in io_client - #1974
amanmaurya92 wants to merge 1 commit into
Conversation
|
While making this change, I also noticed a Since that SDK issue appears to be resolved, we could probably clean this up now. Should I make a separate PR to refactor and remove the |
|
I have no experience with the Dart Lang codebase, but out of curiosity I checked your code (I created the issue). |
|
Hi @brianquinlan, Thanks for looking into this and creating #1979. I do not have a reproduction either. I tested this against This PR was opened under the assumption from #1972 that Given that, I'm happy to close this PR for now until @Keetz provides a minimal reproduction and specifies their client and environment on #1972. If it turns out to affect a different client in this repo, we can address it there. |
|
Thanks @amanmaurya92 ! |
Fixes #1972
This PR resolves an issue where
HEADrequests unexpectedly throw aClientExceptiondue to a mismatch between theContent-Lengthheader and the actual response body length (which is naturally empty forHEADrequests).Because
dart:io'sHttpClientwill sometimes fail when verifying theContent-Lengthof an emptyHEADresponse body, we now interceptHEADrequests inio_client.dart. Instead of attempting to read the body stream, we asynchronously drain the underlying connection (safely swallowing any spuriousdart:iolength-mismatch exceptions) and immediately return the headers with a safe, empty stream.Contribution guidelines:
dart format.Many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.
Note: The Dart team is trialing Gemini Code Assist. Don't take its comments as final Dart team feedback. Use the suggestions if they're helpful; otherwise, wait for a human reviewer.