In my project I need to pass through an authentication protocol to access my application. I have an issue to POST an encoded form data, I will try to be clear. (I can upload only 1 image so find captures at the end, sorry)
The request and headers when using a navigator looks like this:
When I’m trying to do this request with Gatling, I can observe in traces that I have 2 cases:
If I add headers Content-Type and Content-Length with the CORRECT length, or if I remove them, the host and cookies are not the ones I’m supposed to have + content-type and content-length don’t appear in the headers:
(see 2)
If I add headers Content-Type and Content-Length with a WRONG length, I have the correct host and cookies + content-type and content-length appear in the headers (but request if failing obviously):
(see 3)
Also, the encoded form data looks ok when I compare to the one sent by the navigator (same length, same fields etc.)
First thing first, please make sure to use the latest version of Gatling. This is something we require when posting here so we don’t waste time investigating a bug that’s actually already been fixed.
You’ve purposefully removed it from the required information from the topic template, which is a typical sign that you’re using an outdated version Please upgrade.
Then:
make sure that when your comparing with your browser, you follow the same journey and start with empty cookies (typically in anonymous mode)
Gatling automatically computes the content-length if you don’t set it nor the transfer-encoding. In this case, it might not be visible in the logs though.
When using formParam, Gatling automatically sets the content-type to application/x-www-form-urlencoded if the user didn’t provide one. Same, in this case, it might not be visible in the logs though.
cookies and other user-defined request headers are completely unrelated, unless you’re actually using sign to compute one from another
I always use a clean browser to get all the steps needed and make sure to have the correct requests, cookies etc. step by step, it’s not the first time I script this kind of authentication, and usally I don’t set any header for content-type or length.
The point I don’t get is why the host and so cookies used for my request are not the good ones but become the good ones if I intentionally put a wrong content-length. And how to get the correct host and cookies with the correct content ?
The point I don’t get is why the host and so cookies used for my request are not the good ones but become the good ones if I intentionally put a wrong content-length. And how to get the correct host and cookies with the correct content ?
I can’t make sense of this statement, sorry. As I said, these are completely unrelated.
If you still experience an issue after upgrading to the latest version, please provide a reproducer = a simple sample we can run on our side.