Gatling - Setting Authorization header as part of request

你离开我真会死。 提交于 2021-01-29 07:42:46

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!