-f Flag: POST Requests Fail when JSON Strings Contain Special Characters
tarskiandhutch opened this issue · 5 comments
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:
- envoke Siege using -f flag
- urls.txt file lists many POST requests
- POST requests include JSON strings
- 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!
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!
Good to know in the meantime.
Thanks for a great tool!
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"}