Is it possible to retrieve headers from the http response ?
I didn’t found it in the github wiki and API docs.
My use case is to automatically retrieve the ETag hash of a resource to send it in the next request (to have the 304/not change and mimic the client’s behavior).
Hi,
I tried to do a println like this but have a compilation error with 1.2.5 :
/usr/local/gatling/user-files/simulations/staging/CookieCache250.scala:41: error: type mismatch;
found : com.excilys.ebi.gatling.core.Predef.Session => Unit
required: com.excilys.ebi.gatling.core.action.builder.ActionBuilder
(s:Session) => println(s.getAttribute(“aisakosSegs”))
^
My aim is just to check a cookie, It seems to me that the simplest way is to get the value from session as it said here : https://github.com/excilys/gatling/wiki/HTTP that cookies are stored in the session
First, your simulation deson’t compile because you’re missing the ; s in the example below. As the Session class is immutable and one might want to edit it in a Session function, Session functions have to return a Session.
Then, cookies are stored in a CookieStore which is store in the Session, they are note store directly as attributes. The storage key for the CookieStore is “gatling.http.cookies”.
You cant directly print the CookieStore, it has a user-friendly toString method.
As you could see on http://pastebin.com/UxvXrK9F
My feeder is used as it does, there’s the good values in the cookie and in the user-agent.
I’ve put those values in user-agent just for check.
And as you see it said : Check ‘exists’ failed, found None
But there’s the set cookie header
Perhaps because there’s some + in my cookie value ?
Sure, that’s just a more simple way of writing the same thing.
The problem is exactly what you suspected: there’s some special characters in your expression that have a regex meaning.
You have to escape them:
headerRegex(“Set-cookie”, (session: Session) => “aisakosSegs=” + session.getTypedAttributeString.replace("+", “\+”) + “.*”)))