apache / jmeter

Apache JMeter open-source load testing tool for analyzing and measuring the performance of a variety of services
https://jmeter.apache.org/
Apache License 2.0
8.2k stars 2.07k forks source link

Java Implementation not sending `Authorization` and `Host` header #6303

Open dudumiquim opened 1 month ago

dudumiquim commented 1 month ago

Expected behavior

I'm using Java implementation because it is faster than HttpClient4. I expected that my headers would be sent independently of the implementation.

Actual behavior

When I change from HttpClient4 to Java, some headers are not sent.

Steps to reproduce the problem

My Config:

db3d72-e78d2c70-0d6d-4867-b5a7-b9135328de14

When I run using Java Implementation, the Authorization and Host header is not sent

image

When I change from Java to HttpClient4 implementation, Authorization and Host header is sent

image

JMeter Version

5.6.3

Java Version

Java(TM) SE Runtime Environment (build 1.8.0_411-b09)

OS Version

Microsoft Windows [versão 10.0.22631.3737]

buzzerrookie commented 1 month ago

Actually these headers have been sent and you can verify by Wireshark or other network sniffers. The Java HttpURLConnection automatically hides the Authorization header when getting request headers from HttpURLConnection, thus it can not be accessed by user. The Host and User-Agent headers are automatically sent by HttpURLConnection but you can still overwrite them via Header Manager. When the Host and User-Agent headers are set in Header Manager, they will appear in the Request Headers panel. The Authorization header should be placed in HTTP Authorization Manager and it will apper in the Request Headers panel. I don't know whether the two implementations should keep a consistent appearance in the Request Headers panel. If so, I'm glad to help if the JMeter owner determines to improve it.