Trouble in passing "=" (equal) symbol in subsequent request - Jmeter

24,667

Solution 1

It took me a while to understand this, unlike other languages and environments in network standards URIs (URLs) do not use quotes or some escape characters to hide special characters.

Instead, a URL needs to be properly encoded by encoding each individual parameter separately in order to build the complete URL. In JavaScript encoding/decoding of the parameters is done with encodeURIComponent() and decodeURIComponent() respectively.

For example, the following:

http://example.com/?p1=hello=hi&p2=three=3

should be encoded using encodeURIComponent() on each parameters to build the following:

http://example.com/?p1=hello%3Dhi&p2=three%3D3

  • Note that the equal sign used for parameters p1= ... p2= remain as is.
  • Do not try encode/decode the whole URL, it won't work. :)
  • Do not be fooled by what is displayed on a browser address bar/field, that is only the human friendly string, the moment you copy it to the clipboard the browser will encoded it.

Hope this helps someone.

Solution 2

Your application has a problem then, because that's the way it should be sent. Url parameters should be encoded as specified in rfc3986. Browsers can do it automatically even, so that's something that should be fixed on your web app, if it is not working.

If data for a URI component would conflict with a reserved character's purpose as a delimiter, then the conflicting data must be percent-encoded before the URI is formed.

  reserved    = gen-delims / sub-delims

  gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"

  sub-delims  = "!" / "$" / "&" / "'" / "(" / ")"
              / "*" / "+" / "," / ";" / "="

Solution 3

What you are experiencing is URL Encoding - = is a reserved character in URLs and you cannot just append it to your URL unencoded. It needs to be encoded. This obviously already happened in your case. On the server side the url parameters need to be decoded again. This is the job of the container normally, though.

Share:
24,667
Admin
Author by

Admin

Updated on July 09, 2020

Comments

  • Admin
    Admin almost 4 years

    I newly started using jmeter. my application returns an url with encryption value as response which has to be passed as request to get the next page. The encryption value always ends with "=" ex. "http://mycompany.com/enc=EncRypTedValue=". while passing the value as request, the "=" is replaced with some other character like '%3d' ex "http://mycompany.com/enc=EncRypTedValue%3d" . Since the token has been changed my application is not serving the request.

  • Sean the Bean
    Sean the Bean over 6 years
    This is not a proper solution for passing request parameters. A string should be url-encoded, not wrapped in quotes.
  • Meryan
    Meryan almost 6 years
    @SeantheBean aren't all the equal sign going to be encoded to %3d? Which function parses back the value containing an equal sign as a single piece? eg p1="hello = hi"&p2=25 Please point to a complete answer thank you.
  • Sean the Bean
    Sean the Bean almost 6 years
    @Marie Yes, equal signs would be encoded as %3D. The way to decode it depends on the language. For JS, you can use decodeURIComponent (see stackoverflow.com/a/3431528). For PHP, simply use urldecode (php.net/manual/en/function.urldecode.php).