skip to content

Which JMeter property stops the HTTP Authorization Manager from sending BASIC credentials unchallenged?

level: middleimportance: should knowfreq 40%

answer

  1. Ask who speaks first, client or server
  2. A 401 you never see
  3. One property, HttpClient4 only
  4. The default flipped back in 3.2

basics

~10 s

Set httpclient4.auth.preemptive=false in user.properties. The HttpClient4 implementation defaults it to true, so the Authorization header rides on the very first request; with it false, credentials go only after the server sends a challenge.

solid answer

~40 s

`httpclient4.auth.preemptive` is a JMeter property, commented out in the shipped `bin/jmeter.properties` with a documented default of `true`. When true, JMeter registers a request interceptor that looks the URL up in the HTTP Authorization Manager and attaches the `Authorization` header before the request goes out, so the header is visible in a View Results Tree. When you set it `false`, JMeter installs a managed credentials provider instead and the credentials are supplied only in response to a challenge — the extra round trip happens inside one sampler execution, so it lands in that sample's elapsed time rather than as a second row. The setting applies to the HttpClient sampler implementation and to BASIC; DIGEST and Kerberos have their own paths.

go deeper

for a junior

Recall that the HTTP Authorization Manager stores logins per Base URL and that JMeter attaches them for you.

for a middle

Explain that preemptive means the header is sent before any challenge, and name the property and its default.

for a senior

Know that turning it off buys a challenge round trip inside the same sample, and when reproducing that path is worth the cost.

for a principal

Own whether the team's plans model the challenge handshake or skip it, since the choice changes what the protected endpoints are actually exercising.

## What the Authorization Manager is doing The **HTTP Authorization Manager** holds a table of `Base URL`, `Username`, `Password`, `Domain`, `Realm` and `Mechanism` rows. Before a sampler runs, JMeter looks the request URL up in that table. The match is a plain prefix test against the entry's Base URL, evaluated **in table order**, and the first hit wins — there is no longest-match logic, so the most specific URLs must be listed first. Duplicate URLs are ignored. The `Mechanism` column offers `BASIC`, `DIGEST` and `KERBEROS` (plus a deprecated `BASIC_DIGEST` alias). The Java sampler implementation supports only `BASIC`; HttpClient4 supports all three. There is no Bearer mechanism — an OAuth or JWT token belongs in an **HTTP Header Manager** as a literal `Authorization` header, not here. ## What preemptive means here With `httpclient4.auth.preemptive=true` — the documented default, and the behaviour since 3.2 — JMeter adds a request interceptor that runs first on every request. It finds the matching authorization entry, seeds an auth cache with a BASIC scheme for that host, and the `Authorization` header therefore goes out on the **first** request, unprompted. Set the property `false` and that interceptor is not registered. JMeter supplies a managed credentials provider instead, and the flow becomes the classic one: 1. the request goes out with no `Authorization` header; 2. the server answers with a challenge; 3. HttpClient answers the challenge and replays the request. All three steps happen inside a single sampler execution, so you get one sample row whose elapsed time now includes the extra leg — not two rows. ## Why anyone would turn it off - To exercise the challenge path itself, because that is what a real browser does on first contact and you want the server's 401 handling under load. - To avoid leaking credentials to endpoints that never asked for them, when one Base URL prefix is broader than intended. - To reproduce a defect that only appears when the client waits to be asked. And why you would leave it on: it removes a round trip per protected request, and the header is visible in the Tree View Listener's request tab, which makes the plan far easier to debug. ## Neighbouring switches people confuse with it | Setting | What it really controls | |---|---| | `httpclient4.auth.preemptive` | Whether BASIC credentials are sent before a challenge, on the HttpClient sampler | | `Clear auth on each iteration` | Clears cached **Kerberos** subjects at the iteration boundary; it is not about BASIC | | `kerberos.spnego.strip_port` | Whether the port is dropped when building the Kerberos SPN | | `kerberos.spnego.delegate_cred` | Whether credentials are delegated to web servers under SPNEGO; off by default | A further wrinkle from the manual: the Java implementation does preemptive authentication too, but it does not hand the `Authorization` header back when JMeter fetches request headers, so the header can be missing from the listener even though it was sent. On HttpClient4 the header is shown. ## Where to set it Put the line in `bin/user.properties`, or pass `-Jhttpclient4.auth.preemptive=false` on the command line. It is read into a static field when the HttpClient4 implementation class loads, so changing it from a script mid-run does nothing. Passwords, incidentally, are stored unencrypted in the `.jmx` — use variables fed from a config element rather than typing them into the table.

  • Two entries in a JMeter Authorization Manager match the same URL. Which one is used?
    The first one in the table. JMeter tests each Base URL as a prefix in list order and stops at the first match, with no preference for the more specific entry, so specific prefixes must be placed above general ones. Duplicate URLs are ignored.
  • Where does a bearer token belong in a JMeter plan, if not the Authorization Manager?
    In an HTTP Header Manager, as a literal `Authorization` header. The Authorization Manager's Mechanism column offers only BASIC, DIGEST and Kerberos, so it has no way to express a bearer scheme.

saying these in an interview costs you the question

  • Thinks JMeter always waits for a 401 first
  • Looks for the setting as a checkbox on the element
  • Expects the challenge round trip to appear as its own sample
  • Assumes the property also governs Digest and Kerberos
  • Puts an OAuth bearer token in the Authorization Manager