jmeter
jmeter copied to clipboard
JMeter is adding Content-Type header with value as text/plain in request header while recording web application if Content-Type header is missing in POST request
Expected behavior
JMeter should not add its own Content-Type header with value as text/plain in request header while recording even if Content-Type header is missing in the POST request with HttpClient4 implementation or there should be some option to configure the default value for Content-Type if this header is missing in POST request while recording.
Actual behavior
In latest version of JMeter while recording a web application its adding its own Content-Type header with value as text/plain if Content-Type header is not available in the POST request with HttpClient4 implementation. That particular end point doesn't accept text/plain Content-Type hence its throwing 415 status code with message as Unsupported Media Type and unable to proceed recording further. Its blocking our script development.
The same behavior is shown in lower version(5.1.1) of JMeter as well but the value of Content-Type is application/x-www-form-urlencoded if Content-Type header is missing in POST request while recording.
JMeter Version: 5.6.3
JMeter Version: 5.1.1
Steps to reproduce the problem
For security reasons, I will not be able to share the actual endpoint. There are some possible way to reproduce the same and provided the details below: Step 1: Create a API request in Postman with below details Method: POST URL: https://reqres.in Path: /api/users Payload: Payload should be blank Request Headers: Keep default header and make sure Content-Type header is not available Step2: Open JMeter(5.6.3) and create recording template and start recording Step3: In Postman navigate to Files->Settings->Certificates and Enable CA Certificates Step4: In PEM file select and browse and open ApacheJMeterTemporaryRootCA.crt located inside bin folder of JMeter Step5: Navigate to proxy tab and disable use system proxy and enable use custom proxy configuration Step6: Configure proxy with proxy server as localhost and port number same as given in JMeter test script recorder Step7: Go back to postman API request and execute the same from postman Step8: Make sure executed request is recorded in JMeter by navigating to HTTP Test Script Recorder view result tree Step9: In the recorded request check the request header it contains Content-Type header but actual API which we sent from postman doesn't contain that Content-Type header
Attached a sample postman collection for reference: Test.postman_collection.json
JMeter Version
5.6.3
Java Version
17.0.7
OS Version
Windows 10 Prop [22H2]
For reference, the root cause is likely text/plain
default: https://github.com/apache/jmeter/blob/d57e4e535ae96ae88819c0b5b17cab996c578938/src/protocol/http/src/main/kotlin/org/apache/jmeter/protocol/http/util/HTTPArgumentSchema.kt#L40
Hi @vlsi , Thanks for looking into this. Is there a way to override the default Content-Type value with any other value while recording if Content-Type is missing in POST request?