Skip to content

fix(http): NTLM auth with --fail sends duplicate Type 3 request (test 150, flaky) #121

@jonwiggins

Description

@jonwiggins

Summary

Curl test 150 (HTTP with NTLM authorization and --fail) fails intermittently (~40% failure rate). urlx sometimes sends a spurious third HTTP request after NTLM authentication completes successfully.

Expected behavior

With --ntlm --fail, urlx should send exactly 2 requests:

  1. GET with Authorization: NTLM <Type1> (negotiate)
  2. GET with Authorization: NTLM <Type3> (authenticate)

Actual behavior

urlx sometimes sends 3 requests — duplicating request #2 (the NTLM Type 3 auth request). The test runner sees the extra request in the protocol trace and fails the test.

Root cause

In crates/liburlx/src/easy.rs, the is_ntlm_probe flag is set to true at the start of an NTLM exchange (~line 3483) but is never reset after the Type 3 auth succeeds. After the 200 response returns, the probe-retry logic (~line 3638) checks:

if (is_challenge_response || is_ntlm_probe)
    && response.status() != 401
    && !response.is_redirect()
{
    if let Some(body) = current_body.as_deref() {
        if !body.is_empty() {
            // Sends a THIRD request with the full body

Since is_ntlm_probe is still true, the status is 200 (not 401), and there is a body, the code sends a spurious third request.

Suggested fix

Reset is_ntlm_probe = false after the NTLM Type 3 authentication completes (~line 4231), so the probe-retry path doesn't fire on the already-successful response.

Reproduction

./scripts/run-curl-tests.sh 150  # fails ~40% of the time

Metadata

Metadata

Assignees

No one assigned

    Labels

    optioAssigned to Optio AI agent

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions