Add headers for all requests in the middle of simulation

I know that it is possible to add some constant headers in http protocol, but I can’t find a way to add them in scenario.

For example:

scenario(“some scenario”)
.exec(verifyPasswordRequest) //at this moment auth id is received which should be used in all following requests

Is there any option to automatically add header in the middle of scenario?

In jmeter i could use configuration bloc and in LR there was a function web_add_autoheader and another function to remove header.

Auth requests are part of the load test, so I don’t want to move them to separate function to use it in protocol.

Authentication is just an example, there are some other cases when i want something like auto header function.


Sorry, I don’t think we provide such feature.
If your server accept an empty header, you may want to use the header definition at protocol level and set the session variable when you have it.

   HttpProtocolBuilder httpProtocol = http

  ChainBuilder verifyPasswordRequest = exec(
    http("Verify password")

Does that helps?


Yes, i’ve tried suggested workaround but it is not helpful when i need to remove header (it is not about authorization)

Not sure to understand.

  • If you need to remove the header, yes I agree that’s not helpful
  • If you need to remove the value, you can remove the session variable

You can do the same thing for any header:

   HttpProtocolBuilder httpProtocol = http
    .header("X-Other-Header", "#{myToken}");