Search code examples
jmeterhttp-headersperformance-testingload-testing

Apache Jmeter HTTP Header Manager override "Host" Header without appending the port


I'm trying to load test a service which needs a specific "Host" header to route. (and also this service is running on port 9211). In Jmeter config, I added a "Http header manager" and added an override for the said header. But the request seems to have the port appended in the host header like following. I believe this could be a bug in jmeter(or some weird feature). In any case is there a way around this?

I want the "Host" header to be "my-host" and that only without appending the port.

jmeter config

jmeter config

Heder manager setup

Heder manager setup

Actual request headers

actual request headers

Thanks


Solution

  • I don't think this is something you can configure, it's being done under HTTPHC4Impl.setConnectionHeaders() function, the port is being added for "non-default" ports (80 for HTTP or 443 for HTTPS)

    Actually it doesn't contradict with the specification so I would recommend just ignoring it.

    However if you have a specific use case and need to send the Host header without specifying the port - you will need to switch the "Client implementation" of the HTTP Request sampler to Java, the setting lives under "Advanced" tab of the HTTP Request sampler (or better use HTTP Request Defaults if you want the setting to be applied to all HTTP Request samplers)

    enter image description here