fix(http): prevent duplicate NTLM Type 3 request with --fail (test 150)#133
Merged
jonwiggins merged 2 commits intomainfrom Mar 28, 2026
Merged
Conversation
When --fail is used with NTLM auth, the h1 layer skips reading the 401 response body (fail_on_error optimization). However, the connection was still marked as reusable, leaving unread body data on it. When the NTLM Type 3 request reused this connection, it encountered leftover data from the 401 body, causing an HTTP/0.9 parse error. The retry logic in do_single_request then sent the Type 3 again on a new connection — producing a spurious third request that fails curl test 150. Fix: mark connections as non-reusable when fail_on_error skips the body (add !fail_skip to the can_reuse calculation in h1.rs). Also reset the is_ntlm_probe flag after Type 3 auth completes so the probe-retry path cannot fire on subsequent loop iterations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12e801d to
f4cf703
Compare
The `is_ntlm_probe` variable is re-initialized with `let` at the top of each loop iteration, so the `= false` assignment after Type 3 auth was dead code (never read before re-initialization). Remove it and drop the now-unnecessary `mut`. Also fix formatting in h1.rs test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--failis used with NTLM auth, the h1 layer skips reading the 401 response body but still marks the connection as reusable — leaving unread body data on the socket!fail_skipto thecan_reusecalculation in h1.rs so connections with skipped bodies are never returned to the poolis_ntlm_probeflag after Type 3 auth completes for correctnessCloses #121
Test plan
request_fail_on_error_prevents_reuseverifiescan_reuse = falsewhenfail_on_errorskips bodycargo clippyandcargo fmtclean./scripts/run-curl-tests.sh 150should pass consistently (was ~40% failure rate)🤖 Generated with Claude Code