HTTP 307 doesn't keep headers

Hi,

I’m new to use Gatling and i’m facing some issues with it.

Indeed, my get request doesn’t keep the headers when there is a redirection. Do you have any suggestions for me?

Here how I’m doing:

val httpConf = http
.baseURL(“http://url”)
.acceptHeader(“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8”)
.acceptLanguageHeader(“en-US,en;q=0.5”)
.acceptEncodingHeader(“gzip, deflate”)
.userAgentHeader(“Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:16.0) Gecko/20100101 Firefox/16.0”)

val header_1 = Map(“Content-Type” → “application/x-www-form-urlencoded”, some → “header” , … )

val scn = scenario(“Scenario 1”)
.exec(http(“request_1”)
.get("/xxx")
.headers(headers_1)

setUp(scn.inject(atOnceUsers(1)).protocols(httpConf))

Thanks you!

Are you talking about request or response headers?
Which headers exactly?
What makes you think that those should be kept?
Can you share a reproducer?

Hello,

Thanks you for helping.

I’m taking about the request headers. (headers_1 in my example)

When i’m doing wget with my header, i see the redirection with the headers and i get the good response:

wget -d --header=“header1” --header=“header2/” --header=“header3” http://url/

I’ll try to share a reproducer but i don’t know if i can. Do you know if we can somehow force the headers?

Thanks again.
Raj

I’m having a hard time finding out which headers should be propagated. As usual, RFCs are incomplete at best…
Gatling currently have a close list of propagated headers: https://github.com/gatling/gatling/blob/master/gatling-http/src/main/scala/io/gatling/http/ahc/AsyncHandlerActor.scala#L61-L68

If anyone could help find a pointer to the proper behavior, I’d gladly implement it.

Cheers,

The problem is that my headers was not usual headers.

So, the solution for my issue was to disable the redirection and use the “location” header who contains the url of the redirection to make another call with the headers of my first request:

.exec(http(“Get 1”)
.get(url_1)

.disableFollowRedirect
.headers(headers_1)
.check(status.is(307))
.check(header(“Location”).find.saveAs(“redirect_url”)))
.pause(1)
.exec(http(“Get redirection”)
.get(url_2)
.headers(headers_1)
.check(status.is(200)))

That’s the workaround.
But I will fix it properly: https://github.com/gatling/gatling/issues/2521

Fixed, thanks for reporting!