Hello,
I have Java 11 + Maven project with Gatling. Today I upgraded gatling from version 3.9.5 to 3.10.3. Necessary changes for DSL were done (like exitBlockOnFail)
Also I remove tens of .exec()
blocks inside my scenarios thanks to changes at 3.10 version
After that I found an issue. For one of the request the Content-Type header somehow was omitted. Rest of headers was properly added. Please, check example of request and also output from 3.9.5 and 3.10.3 versions
Request:
public static final ActionBuilder myRequest =
http("Some request")
.post(someEndpoint)
.ignoreProtocolHeaders()
.header("Content-Type", "multipart/form-data")
.header("apiKey", apiKey)
.header("User-Agent", userAgent)
.check(status().is(200));
Here it is necessary to ignore headers provided by protocolBuilder
cuz I have to use different API Key to start a user journey, for rest of requests Im using headers from protocolBuilder
set globally.
Output from version 3.10.3
=========================
HTTP request:
POST someUrl
headers:
apiKey: <<<<>>>>>>
User-Agent: <<<<>>>>>>
accept: */*
host: <<<<>>>>>>
content-length: 0
=========================
HTTP response:
version:
HTTP/1.1
status:
415 Unsupported Media Type
headers:
Date: Wed, 10 Jan 2024 10:50:05 GMT
Content-Length: 0
Connection: keep-alive
access-control-allow-headers: Content-Type,User-Agent,Origin,Accept,Accept-Encoding,Authorization
access-control-allow-methods: GET,POST,DELETE,OPTIONS
access-control-allow-origin: *
server: <<<<>>>>>>
x-envoy-upstream-service-time: 36
x-ipvproxy-from-cluster: <<<<>>>>>>
x-ratelimit-limit-year: 100000000
x-ratelimit-remaining-year: 99987948
api-correlation-id: <<<<>>>>>>
<<<<<<<<<<<<<<<<<<<<<<<<<
As you can use, sent request does not contain Content-Type header, but apiKey and User-Agent were properly added
Output from version 3.9.5
=========================
HTTP request:
POST someUrl
headers:
Content-Type: multipart/form-data
apiKey: <<<<>>>>>>
User-Agent: <<<<>>>>>>
accept: */*
host: <<<<>>>>>>
content-length: 0
=========================
HTTP response:
status:
200 OK
headers:
Date: Wed, 10 Jan 2024 10:51:50 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
access-control-allow-headers: Content-Type,User-Agent,Origin,Accept,Accept-Encoding,Authorization
access-control-allow-methods: GET,POST,DELETE,OPTIONS
access-control-allow-origin: *
server: <<<<>>>>>>
x-envoy-upstream-service-time: 36
x-ratelimit-limit-year: 100000000
x-ratelimit-remaining-year: 99987946
api-correlation-id: <<<<>>>>>>
body:
SOME BODY
<<<<<<<<<<<<<<<<<<<<<<<<<
As you can see here the Content-Type header was properly added.
I can also show you the value of globally set headers:
http
.baseUrl(baseUrl)
.header("apiKey", apiKey)
.userAgentHeader(userAgent);
As you can see by ignoring protocolHeaders I want to override apiKey value and userAgent
Do you have any idea what’s going on here?