Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-f Flag: POST Requests Fail when JSON Strings Contain Special Characters #189

Open
tarskiandhutch opened this issue Mar 23, 2021 · 5 comments

Comments

@tarskiandhutch
Copy link

tarskiandhutch commented Mar 23, 2021

This error seems to be limited to a very specific use case, but it's one that I'd imagine could come up often for folks load testing backend APIs that manipulate text data.

Here are the conditions:

  1. envoke Siege using -f flag
  2. urls.txt file lists many POST requests
  3. POST requests include JSON strings
  4. JSON strings include a dollar sign $ (and maybe other special chars, but this is where I see the error in my case)

For the request that includes a $, the endpoint logs will show that it only received the content of the request up to (and excluding) the $.

For instance, your urls.txt looks like this (using dummy urls and such because my case is proprietary):

https://site.com POST {"user": "jojo", "sentence": "that is a big apple"}
https://site.com POST {"user": "weehaa", "sentence": "that will cost you $10 for every mile"}
https://site.com POST {"user": "person2", "sentence": "time for change"}
...

And your Siege call is like this:

siege --content-type "application/json" -f urls.txt -c14 -d1

In my case, my logs show that the request body for the request in line 2 before the transaction was: {"user": "weehaa", "sentence": "that will cost you . In other words, Siege appears to have stopped parsing at the $.

If you take line 2 from the above and curl the same request, you would do something like:

curl  -v --header "Content-Type: application/json" POST --data '{"user": "weehaa", "sentence": "that will cost you $10 for every mile"}' https://site.com

In my case, this curl produces a perfectly good response. However, the same call in Siege is not workable (at least not when I submit many URLs using the -f flag). Is there a way to solve this on my end, or is this actually a problem with Siege?

Thanks!

@JoeDog
Copy link
Owner

JoeDog commented Mar 23, 2021 via email

@tarskiandhutch
Copy link
Author

Interesting! Is it just $s then? If so, then I'm just going to avoid $s in our test requests.

Thanks for the quick response!

@JoeDog
Copy link
Owner

JoeDog commented Mar 23, 2021 via email

@tarskiandhutch
Copy link
Author

tarskiandhutch commented Mar 23, 2021

Good to know in the meantime.

Thanks for a great tool!

@JoeDog
Copy link
Owner

JoeDog commented Jul 16, 2021

The fix is in the repo. You can escape dollar signs in your URL.
https://site.com POST {"user": "weehaa", "sentence": "that will cost you \$10 for every mile"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants