加特林-将授权标头设置为请求的一部分 [英] Gatling - Setting Authorization header as part of request

查看:59
本文介绍了加特林-将授权标头设置为请求的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试根据Feeder中的值设置我的Authorization标头.成功设置其他标头后,授权标头似乎已被剥离/覆盖.

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}")

正在发出请求,并且服务器看到"X-Hello"标头,但没有看到"Authorization"标头设置为完全相同的值.

The request is being made, and the server sees the "X-Hello" header, but not the "Authorization" header set to the exact same value.

文档建议我可以将Authorization标头设置为http协议的一部分(我不这样做)-但我需要根据请求获取它,因为我需要从会话中获取该值.有办法防止它被剥夺吗?

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?

(这是使用加特林3.0)

(This is using Gatling 3.0)

推荐答案

我发现我做错了-我错误地将我的网址设置为 https://主机名/路径,但是在重定向后没有发送Authorization标头,尽管其余标头是.(这不是错误-这是故意的行为.)

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!

这篇关于加特林-将授权标头设置为请求的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆