Hi,
My co-worker introduced me to Gatling and after going over some of the tutorials I know this is just the thing I need.
However got a bit of a scenario, not sure if and how to deal with it Gatling (I’m a C# developer, but this Scala read pretty straight forward…it seems)
I got a web api (using asp.net web api) that get used by mobile applications.
The API first need to make a call to the “login” method passing in the username and password and return a token (GUID) which are injected in every subsequent call’s header.
It’s important to remember if a login call are made for the same account, a new token are generated, rendering the previous one invalid (a 401 will occur)
I don’t use sessions. The whole api is RESTful and totally stateless.
So I guess my question is:
- How can I “remember” the token made for the login token for that specific user and
- How to I inject that in the header?
For what it might help to explain what I mean, this is for instance how you’d make a call to the “about” method (from a demo, hence the this and that = some textbox.val)
:
function setHeaders(xhr) {
var encoded = $(’#txtToken’).val();
xhr.setRequestHeader(“Authorization-Token”, encoded);
}
$.ajax({
url: $(’#txtUrl’).val(),
beforeSend: function (xhr) {
setHeaders(xhr);
},
type: ‘GET’,
data: model,
dataType: ‘json’,
success: function (data) {
// do what you gotta do
},
error: function (error) {
showError(error);
}
});