How do I pass a complex cookie to ab for testing?

Paul McMillan picture Paul McMillan · Oct 29, 2010 · Viewed 11.5k times · Source

I'm using ab to test my app, and I'm having trouble passing the correct cookie. My cookie data looks like this:

messages=95925d68c34fcc68b3fcc2e5061a45278c35af41$[[\\\\"__json_message\\\\"\\\\05420\\\\054\\\\"Data\\\\"]]

I can't figure out how to get the second part of the string to ab to send to my server. I'm doing something like

ab -C messages='95*snip*5af41$[[\\\\"__json_message\\\\"\\\\05420\\\\054\\\\"Data\\\\"]]' http://example.com:80/

Everything up to the [ is sent, but nothing from there on. I'm concerned [ is some kind of control to my shell that is getting escaped, but I'm not quite sure what the deal is. I thought the single quotes should allow me to put anything but another single quote inside of them.

Answer

Paul McMillan picture Paul McMillan · Oct 29, 2010

I figured it out. Turns out the correct syntax is:

ab -C 'messages="93bad4084536e6ee5839de07d59c8a42eadf014f$[[\"__json_message\"\05420\054\"Houston3\"]]"' http://localhost:8000/