Hi,
I’m not an expert in Scala nor Gatling for the moment, but I would like to know how can I access session attributes inside the byteArray callback function.
My byte array is dependent from context variables different for each virtual user.
Regards,
Hi Gabriel,
If I’m right, there’s no way to use session values in byteArrayBody.
We could add this possibility by allowing you to pass a (Session => Array[Byte]) function, what do you think about this idea ?
Cheers,
Romain
Thanks for your answer.
I think it’s the best way to realize it as the session can contains almost everything.
At the opposite, what is the easier way to handle the http response in byte array form?
Regards,
Gabriel
Hi Gabriel,
I’ve added the issue here : https://github.com/excilys/gatling/issues/606
As for the response handling, what do need to do exactly ? As you may know, we provide checks, but they are not “byte-array-based”, they are based on strings.
If you provide us with more information about your use case, we may add support for byte-array-based checks.
Cheers,
Romain
Hi Romain,
I need to test a product that is based on a proprietary protocol sent over HTTP, in fact it is mainly based on custom encryption, so I need to be able to send binary data and to process data returned by the server which is binary too.
So for the response, a function like saveAs, i.e. saveAsBytes to be able to process inside an “exec (s:Session)” manner would be perfect, morover the only way (before handling response with the Java API) to validate the response is with the HTTP status code, so I imagine writing it in gatling with “check(status.is(200)).saveAsBytes(“data”)”
Regards,
Gabriel
Hi,
Actually, the saveAs method should be called on the status method. Which forces us, seeing the current API, to have a check specialized in getting response as bytes and checking something on it.
I currently can’t think of a nice solution for your problem (I have some work to be done here ;)) but I’ll think of it !
If you have any idea, they are most welcome 
Cheers,
Romain
PS: It could be a check to verify that the body is not empty, and if not, save it either as bytes or as string… what do you think of it ?
Yes, the presence of body can be a good solution. Is the last http status code stored in session, in order to handle the response data differently?
Cheers,
Gabriel
The last HTTP status code isn’t saved (sorry, I forgot this one ;))
So, should we open an issue for a new responseBodyBytes check (and maybe a responseBodyString)?
That would be very easy to do, but beware that depending on your use case, it might have a big impact on your simulation (just like storing huge amounts of data in the HTTP session in a webapp is a bad idea).