convert correlated value from url to html mode

Hi Team,

Please help in converting a string from URL to HTML mode in gatling.

I have the following string that got captured from headers/cookies, which has to be passed as header in other requests in html format.

Which function should i use to convert?

a2=%
3Bdx1Rx3Tjip9bozPu5UiZUUz0vWMdLqYD3YJSWa%2BMAP3BMqjY9NbkMUR46F%2BC1yhbsO2VSiaEB%2BRHE2ItowKvrUKnGfa7ZVhYr1PSKOCuvc5kWi54CHasePpEYG%2xVkt6oLIVu5AEVLpIEgN%2Fe%2FqMUvjQnJGH%2B7P0uGi4WRiaL%2BjE8dWdVWerCY5BtSQw0KGDe2TSHOfnO2UjTXos4U3inDEIuYU7Y7HCHlhrwEcr9vpR4%3D

Thanks & Regards,
Srinivas M

No idea what kind of encoding this is.

Hi Stephane,

Sorry if I am not clear on my request.

Just have to decode the URL format. like below

a%3Bdx1Rx3Tjip9bozPu5UiZUUz0vWMdLqYD3YJSWa%2BMAP3BMqjY9NbkMUR46F%2BC1yhbsO2VSiaEB%2BRHE2ItowKvrUKnGfa7ZVhYr1PSKOCudUjzghPlhyGxS0WxoolX4Phjy3yqXDB4GPUzL9JpmETJpQ2En0%2BOHMRMHkN%2FcsO98zM%3D0TybtzXGP%2B%2Fp9fL77nIw%2BjH9mNC

to

a;dx1Rx3Tjip9bozPu5UiZUUz0vWMdLqYD3YJSWa+MAP3BMqjY9NbkMUR46F+C1yhbsO2VSiaEB+RHE2ItowKvrUKnGfa7ZVhYr1PSKOCudUjzghPlhyGxS0WxoolX4Phjy3yqXDB4GPUzL9JpmETJpQ2En0+OHMRMHkN/csO98zM=0TybtzXGP+/p9fL77nIw+jH9mNC

I used https://www.urldecoder.org/ to convert.

So, checking if we have any function or code available in Gatling.

Thanks & Regards,
Srinivas M

Use java.net.URLDecoder#decode.

Hi Stephane,

Thank you.

Tried this .header(“Authorization”, java.net.URLDecoder.decode(“OAuth ${OAUTHID}”)) and .header(“Authorization”, java.net.URLDecoder.decode(“OAuth ${OAUTHID}”, “UTF-8”)), no luck the value is still passing in encoded form.

exec(http("uploadSession")
    .put(upluri + "/uploadSession?UploadFlow=guf&Src=TST&redEye=true&autoRotate=true&colorCorrect=true&ImageCompression=Y&AlbumCaptionUTF8=album%2006/09/2020&AlbumDate=1591672571886")
  .header("Authorization", java.net.URLDecoder.decode("OAuth ${OAUTHID}"))
      .header("Accept", "application/json")

)

Any other suggestions.

Thanks & Regards,
Srinivas M


Don’t use Gatling EL Strings in random places and expect them to magically work.

From https://gatling.io/docs/current/session/expression_el/:
This Expression Language only works on String values being passed to Gatling DSL methods.

If you want to bring your own code, you have to stick to code and use the Session API.

Sorry, I was new to this tool and syntax. Will try and let you know.

Thanks a lot.

Thanks & Regards,
Srinivas M

Hi Stephane,

This one worked.

.header(“Authorization”, session => session(“OAUTHID”).validate[String].map(URLDecoder.decode))

Thanks & Regards,
Srinivas M


Exactly! :clap: