Hello All,
Kindly assist me, as I am facing this issue for many days, I tried with diff methods but did not get the right resolution.
Need to get the value from the response header for correlation.
Ex:
Response header:
Content-Type: application/json
Connection: close
vary: Accept-Encoding
Y-session-code: globe:qeyJhbGciOiwqewqJSUzI1NiJ9.qeyJqdGkiOiJ0b2tlbi1jNDIyNDBmMC1wwkZGVjLTQ2MjctODZlNS0qwqwwYTRmNWRlYzkxZjIiLCfrfrJpc3MiOiJmca
GEtaXNzdWVyIiwic3ViIjoiVVNFfrfeUklEOmerfefJvbHQ6M2fwefwMwYzlkOTktNwefwDkxNy00YTI2LTk3YWYtN2RmNWI0werfwNWE3NDIxIiwiaWFwefw0Ijad
content-encoding: gzip
I need to capture the value of “Y-session-code:”
i.e.
globe:qeyJhbGciOiwqewqJSUzI1NiJ9.qeyJqdGkiOiJ0b2tlbi1jNDIyNDBmMC1wwkZGVjLTQ2MjctODZlNS0qwqwwYTRmNWRlYzkxZjIiLCfrfrJpc3MiOiJmca
GEtaXNzdWVyIiwic3ViIjoiVVNFfrfeUklEOmerfefJvbHQ6M2fwefwMwYzlkOTktNwefwDkxNy00YTI2LTk3YWYtN2RmNWI0werfwNWE3NDIxIiwiaWFwefw0Ijad
Tried below code:
.check(headerRegex("Y-session-code:", "(.+?)\\n").ofType[(String, String)].saveAs("ysessionCode)))
Thanks!
Hi @hiteshbansal,
Welcome aboard!
If I understand well, you want the whole value of the Y-session-code
header?
You can use header
check
For instance:
.check(header("Y-session-code").saveAs("ysessionCode"))
Does that help?
Cheers!
Hi @sbrevet
Thankyou, it is working
Having one more query on same, please assist here as well. I need a string instead of full header’s value
Ex:
Content-Type: application/json
Connection: close
vary: Accept-Encoding
Y-session-code: globe:qeyJhbGciOiwqewqJSUzI1NiJ9.qeyJqdGkiOiJ0b2tlbi1jNDIyNDBmMC1wwkZGVjLTQ2MjctODZlNS0qwqwwYTRmNWRlYzkxZjIiLCfrfrJpc3MiOiJmca
GEtaXNzdWVyIiwic3ViIjoiVVNFfrfeUklEOmerfefJvbHQ6M2fwefwMwYzlkOTktNwefwDkxNy00YTI2LTk3YWYtN2RmNWI0werfwNWE3NDIxIiwiaWFwefw0IjadQpGDuqMrwrwBGGuiy8Q0axI14G2MzjvL_h6dZguO7kBScuOwaxY5hUwlsi_ILCnYsDjkMUX3MWgNNgqiugZWm9KlDWTkxglMZRAsnDms84eC-WMHrUrwrwkHrMe6OJln_RQy2Ip-_u81dJ8ewrwb3RAdbELiH7z11PrQ; Max-Age=120000; Expires=Mon, 18 jan 2050 09:53:27 IST; Path=/; Secure; HTTPSOnly; SameSite=None
vary: Accept-Encoding
content-encoding: gzip
I want the below data, not a full header value:
qeyJhbGciOiwqewqJSUzI1NiJ9.qeyJqdGkiOiJ0b2tlbi1jNDIyNDBmMC1wwkZGVjLTQ2MjctODZlNS0qwqwwYTRmNWRlYzkxZjIiLCfrfrJpc3MiOiJmca
GEtaXNzdWVyIiwic3ViIjoiVVNFfrfeUklEOmerfefJvbHQ6M2fwefwMwYzlkOTktNwefwDkxNy00YTI2LTk3YWYtN2RmNWI0werfwNWE3NDIxIiwiaWFwefw0IjadQpGDuqMrwrwBGGuiy8Q0axI14G2MzjvL_h6dZguO7kBScuOwaxY5hUwlsi_ILCnYsDjkMUX3MWgNNgqiugZWm9KlDWTkxglMZRAsnDms84eC-WMHrUrwrwkHrMe6OJln_RQy2Ip-_u81dJ8ewrwb3RAdbELiH7z11PrQ; Max-Age=120000; Expires=Mon, 18 jan 2050 09:53:27 IST
There’s something that feels weird here. ; Max-Age=120000; Expires=Mon, 18 jan 2050 09:53:27 IST
are typically set-cookie
attributes.
Where does the text you’re pasting here come from?
Are you sure you’re not confusing/mixing headers and cookies? Gatling handles standard cookies automatically for you?
Yes @sbrevet you are right, these thing comes generally in cookies
but this thing is also passing in this Y-session-code, thats a application behaviour, so i have to pass this in subsequent requests, so i need this whole string
“qeyJhbGciOiwqewqJSUzI1NiJ9.qeyJqdGkiOiJ0b2tlbi1jNDIyNDBmMC1wwkZGVjLTQ2MjctODZlNS0qwqwwYTRmNWRlYzkxZjIiLCfrfrJpc3MiOiJmca
GEtaXNzdWVyIiwic3ViIjoiVVNFfrfeUklEOmerfefJvbHQ6M2fwefwMwYzlkOTktNwefwDkxNy00YTI2LTk3YWYtN2RmNWI0werfwNWE3NDIxIiwiaWFwefw0IjadQpGDuqMrwrwBGGuiy8Q0axI14G2MzjvL_h6dZguO7kBScuOwaxY5hUwlsi_ILCnYsDjkMUX3MWgNNgqiugZWm9KlDWTkxglMZRAsnDms84eC-WMHrUrwrwkHrMe6OJln_RQy2Ip-_u81dJ8ewrwb3RAdbELiH7z11PrQ; Max-Age=120000; Expires=Mon, 18 jan 2050 09:53:27 IST”
Again, could you please explain where you copied this text you’re pasting here? Chrome dev tools?
It seems that the value you pasted contains a line feed, which is strictly forbidden in a HTTP header value.
Hi @slandelle
I copied this text from “Chrome dev tools” only.
There was some misunderstanding, apologies for that, which I got from my colleague.
I just verified and I am rephrasing my query again.
Yes, you are right this comes from set-cookies only from response header
Response header:
Connection: close
set-cookie: st=eyJhbGcidwedeOiJSUzI1NiJ9.eyJqdGkiOiJ0b2tlbi0xOTkzMeddezdiMi1hMmNkLTQxMmQtOWQ1Zi0zOGI2MjM2MGE0ODkiLCJpc3MiOiJmcGEtaXNzdWVyIiwic3ViIjoiVVNFUklEOmJvbHQ6MjViMTU3MjEtMTdjZS00OGFjLWE3NTktNzc4NTQxNzgyNWYyIiwiaWF0IjoxNjc3ODYwNDA3eLCJleHAiOjE5OTMyMjA0MDcsInR5cGUiOiJBQ0NFU1NfVE9LRU4iLCJ2ZXefeJzaW9uIjoidjEiLCJhbm9ueW1vdXMiOnRydWUsImRldmljZUlkIjoiNjFkNDk2ZmI2M2RkYjgwZWU2MmE5MjQ4ZGZkYjczODMifQ.fe-nRXp_W7hYXMHMQpU0vjVffrfFda68UOSwdDe4XlkTaBbTmssn7Gm1psCbyvZQIU1Q_b5ZVgAvrHxHYMFKmY5NIhyJ2xap19Y-s3PmaPyaVzK5UgggECzNfFE_pfx1SKD9zvmadUKXY4Vu3vbUK5j_i1l6Nq21VFgjKhtc_TCwW_vLgBnAQ8MgrgrqCEt8pweoh-SWx6lAvhuzdhr8MPzgrgroqvXjIRcb5i3Lny8Kx6WtwTFpis2QMZ7bQJSl6cU-yoV-yh3C1dVpgrgr5wZcb3h_9ad8ywR-grgrL9r8fpqu2Gapxg; Max-Age=41536000000; Expires=Mon, 18 Jan 2050 16:20:08 IST; Path=/; Secure; HTTPOnly; SameSite=None
vary: Accept-Encoding
I need to pass below string in the session token
eyJhbGcidwedeOiJSUzI1NiJ9.eyJqdGkiOiJ0b2tlbi0xOTkzMeddezdiMi1hMmNkLTQxMmQtOWQ1Zi0zOGI2MjM2MGE0ODkiLCJpc3MiOiJmcGEtaXNzdWVyIiwic3ViIjoiVVNFUklEOmJvbHQ6MjViMTU3MjEtMTdjZS00OGFjLWE3NTktNzc4NTQxNzgyNWYyIiwiaWF0IjoxNjc3ODYwNDA3eLCJleHAiOjE5OTMyMjA0MDcsInR5cGUiOiJBQ0NFU1NfVE9LRU4iLCJ2ZXefeJzaW9uIjoidjEiLCJhbm9ueW1vdXMiOnRydWUsImRldmljZUlkIjoiNjFkNDk2ZmI2M2RkYjgwZWU2MmE5MjQ4ZGZkYjczODMifQ.fe-nRXp_W7hYXMHMQpU0vjVffrfFda68UOSwdDe4XlkTaBbTmssn7Gm1psCbyvZQIU1Q_b5ZVgAvrHxHYMFKmY5NIhyJ2xap19Y-s3PmaPyaVzK5UgggECzNfFE_pfx1SKD9zvmadUKXY4Vu3vbUK5j_i1l6Nq21VFgjKhtc_TCwW_vLgBnAQ8MgrgrqCEt8pweoh-SWx6lAvhuzdhr8MPzgrgroqvXjIRcb5i3Lny8Kx6WtwTFpis2QMZ7bQJSl6cU-yoV-yh3C1dVpgrgr5wZcb3h_9ad8ywR-grgrL9r8fpqu2Gapxg
how can i get this string from the above header.
Kindly assist.
Thanks!
Gatling handles cookies transparently.
You can extract the value of a given cookie stored in the virtual user’s internal cookie jar so you can reuse it for other needs: Gatling - HTTP Helpers
So if you do:
exec(getCookieValue(CookieKey("st")))
the value of the st
cookie will be copied into the virtual user’s Session under the st
key and you’ll be able to use it like any other Session attribute (Gatling EL, Session API).
1 Like
Thankyou @slandelle for sharing the information
Its works for me.
Regards