问题
I'm trying to set my Authorization header based on a value from a feeder. It looks like the authorization header is being stripped/overwritten, when other headers are being successfully set.
exec(http("Initialise Transaction")
.put("/transaction")
.header("Authorization","bearer ${token}")
.header("X-Hello","bearer ${token}")
The request is being made, and the server sees the "X-Hello" header, but not the "Authorization" header set to the exact same value.
Documentation suggests I can set the Authorization header as part of the http protocol (I'm not doing that) - but I need it based on the request as I need the value to come from the session. Is there a way to prevent it being stripped?
(This is using Gatling 3.0)
回答1:
I found what I was doing wrong - I'd mistakenly set my url to be http://hostname/path - my server was set to redirect to https://hostname/path, but the Authorization header wasn't being sent after the redirect, although the remaining headers were. (This isn't a bug - it's deliberate behaviour.)
I hope that helps someone!
来源:https://stackoverflow.com/questions/53782615/gatling-setting-authorization-header-as-part-of-request