If I need a string to actually contain “${foo}” in a context where Gatling EL is used, is there something that I can do that will make Gatling return the actual string, instead of replacing with a non-existent session variable? Like escaping the $ sign or something?
Nope, we didn’t implement escaping. If it was to be done, it would be $${} (like Scala string interpolation). PR welcome
Is there something like RawStringBody() which does NOT take a Gatling EL and returns a Body?
Nope. Believe it or not, you're the first one to ask.
Looking at the code, it looks like it should be a pretty straight-forward change. There is a line that looks like:
`
def elExpr: Parser[Part[Any]] = “${” ~> sessionObject <~ “}”
`
Which would need to be modified like so
def notEscaped: Parser[Part[Any]] = "(?<![$])" // or **(?:(?<=^)|(?<=[^$]))** def elExpr: Parser[Part[Any]] = notEscaped ~ "${" ~> sessionObject <~ "}"
Then add escapedExpr, something like this:
def escapedExpr: Parser[Part[Any]] = "$${[^}]*}" ^^ {_.substring(1)}
And obviously, amend the definition of the expression
`
def multivaluedExpr: Parser[List[Part[Any]]] = ( elExpr | escapedExpr | staticPart ).*
`
Look about right?
Sorry I can’t try it out and send a PR, I haven’t had time to set up to build Gatling as of yet. One of these days…
Not quite right, just realized I did not flag regex strings as such. Corrected below.
Sorry I can't try it out and send a PR, I haven't had time to set up to
build Gatling as of yet. One of these days...
Come on. It's just a matter of cloning on Github and installing sbt. And
adding some tests in ELSpec.
Let me look into doing that this week.
Would be much appreciated, thanks!