I want to set a custom cookie while making a HTTP request. any pointers to how this must be done?
Thanks
I want to set a custom cookie while making a HTTP request. any pointers to how this must be done?
Thanks
Hi,
Before answering your question, could you please explain your use case?
How come you send cookies that didn't come from the server in the first
place?
Stéphane
hi,
The user reaches my application via a hand-off from another application, which sets a certain cookie. I want to run the gatling tests starting from my application (after the hand-off).
MLN
OK, makes sense
Currently, you'll have to hack and manually initialize the CookieStore
that's stored in the user Session.
.exec(session => {
import java.net.URI
import com.ning.http.client.Cookie
import com.excilys.ebi.gatling.http.cookie.CookieStore
val customCookie = new Cookie("TODOdomain", "TODOname", "TODOvalue",
"TODOpath", 100000000, false)
val cookieStore = CookieStore(new URI("TODOuri"), List(customCookie))
session.set("gatling.http.cookies", cookieStore)
})
You'll probably have to first use a Feeder in order to populate the TODOXXX
values into the session, and then use session.getAttribute in order to
retrieve them.
I guess it could be interesting to have a built-in for populating
cookies... I will open an issue for 2.0.
Cheers,
Stéphane
Thanks.
You’re welcome.
For the record, I’ve opened a feature request:
https://github.com/excilys/gatling/issues/902
Hi,
I have done this very easily with headers in a simulation :
…
.headers(headers ++ Map(“Cookie” → “myCookieId=${VALUE_FROM_FEEDER}”, …)
…
Cheers
But if you do that, your “manual” cookie will only be sent on the request it’s declared. Unless the server returns it in the response, it won’t make it into the CookieStore, and won’t be sent with the next requests.
Yes, my needs are for “one shot” cookie
how do I set multiple cookies using .headers
. Is it possible?