Skip to content

Allow 401 status without requiring HTTP authentication#120

Merged
3dgiordano merged 2 commits into
developmentfrom
401-NO-HTTP-AUTH
Jul 9, 2026
Merged

Allow 401 status without requiring HTTP authentication#120
3dgiordano merged 2 commits into
developmentfrom
401-NO-HTTP-AUTH

Conversation

@3dgiordano

Copy link
Copy Markdown
Collaborator

This pull request introduces a custom protocol handler to improve how HTTP 401 responses are handled in the BlazeMeter Jetty-based HTTP client. The main goal is to allow 401 responses without a WWW-Authenticate header (common with app-level authentication like JWT or API keys) to be returned as normal responses, matching the behavior of JMeter's HttpClient4. Previously, Jetty would treat these as protocol violations and fail the exchange. The change is validated with new unit tests.

Authentication protocol handler improvements:

  • Added CustomWwwAuthenticationProtocolHandler as a replacement for Jetty's default handler, allowing 401 responses without WWW-Authenticate to be returned to the application instead of failing the request.
  • Updated HTTP2JettyClient to install the custom handler on all internal HttpClient instances after startup. [1] [2] [3]

Testing and test infrastructure:

  • Added a new test case to verify that a 401 response without a WWW-Authenticate header is handled as a normal 401 (not a protocol error), both with and without an authentication manager configured. [1] [2]
  • Extended ServerBuilder to support a test path (SERVER_PATH_401_NO_WWW_AUTHENTICATE) that returns a 401 without the header, and updated the test server logic accordingly. [1] [2]

@Baraujo25

Copy link
Copy Markdown
Collaborator

Approved! I really liked the idea of having the jetty/ package ❤️ I feel like we are going to have a lot of mods inside-there 😅

@3dgiordano 3dgiordano merged commit 42ec366 into development Jul 9, 2026
1 check passed
@3dgiordano 3dgiordano deleted the 401-NO-HTTP-AUTH branch July 9, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants