timkay / aws

Easy command line access to Amazon EC2, S3, SQS, ELB, and SDB
http://timkay.com/aws/
426 stars 125 forks source link

sqssend message body always encoded #33

Closed razorsmith closed 11 years ago

razorsmith commented 11 years ago

I am trying to send a message to an sqs queue where the body looks like "folder/sub-folder/filename.txt"

The resulting message posted to SQS is encoded looking like "folder%2Fsub-folder%2Ffilename.txt

I don't want to have to change other downstream processing to handle the encoding and would really like if the aws api tool could send the message appropriately.

I attempted to use the --curl-options but to no avail.

Is it a bug or am I just being a numpty?

timkay commented 11 years ago

It's a good question. The documentationhttp://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/Query_QuerySendMessage.html indicates that only certain characters are allowed, and that the request will be rejected otherwise. My thoughts were that messages should be able to contain whatever, so the code avoids the issue by percent encoding.

The question is, what characters should be encoded.... There are lots of answers to this question, depending on the context. I'll update the code to be more precise about which characters get encoded.

...Tim

On Thu, Jan 10, 2013 at 10:02 AM, razorsmith notifications@github.comwrote:

I am trying to send a message to an sqs queue where the body looks like "folder/sub-folder/filename.txt"

The resulting message posted to SQS is encoded looking like "folder%2Fsub-folder%2Ffilename.txt

I don't want to have to change other downstream processing to handle the encoding and would really like if the aws api tool could send the message appropriately.

I attempted to use the --curl-options but to no avail.

Is it a bug or am I just being a numpty?

— Reply to this email directly or view it on GitHubhttps://github.com/timkay/aws/issues/33.

Timothy Kay m: +1-650-248-0123 Skype: timkay Boopsie - Why search when you can FIND!

timkay commented 11 years ago

I pushed a new version with this change. I am not in a position to test it, so please let me know if it works.

...Tim

On Thu, Jan 10, 2013 at 10:56 AM, Timothy Kay timkay@not.com wrote:

It's a good question. The documentationhttp://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/Query_QuerySendMessage.html indicates that only certain characters are allowed, and that the request will be rejected otherwise. My thoughts were that messages should be able to contain whatever, so the code avoids the issue by percent encoding.

The question is, what characters should be encoded.... There are lots of answers to this question, depending on the context. I'll update the code to be more precise about which characters get encoded.

...Tim

On Thu, Jan 10, 2013 at 10:02 AM, razorsmith notifications@github.comwrote:

I am trying to send a message to an sqs queue where the body looks like "folder/sub-folder/filename.txt"

The resulting message posted to SQS is encoded looking like "folder%2Fsub-folder%2Ffilename.txt

I don't want to have to change other downstream processing to handle the encoding and would really like if the aws api tool could send the message appropriately.

I attempted to use the --curl-options but to no avail.

Is it a bug or am I just being a numpty?

— Reply to this email directly or view it on GitHubhttps://github.com/timkay/aws/issues/33.

Timothy Kay m: +1-650-248-0123 Skype: timkay Boopsie - Why search when you can FIND!

Timothy Kay m: +1-650-248-0123 Skype: timkay Boopsie - Why search when you can FIND!

jberryman commented 11 years ago

What is the new behavior?

FWIW, the python boto lib apparently base-64 encodes messages. That might be a less ad-hoc approach, unless you're sure url-encoding meets the spec they link to.

Regardless I think aws should decode appropriately on read, with an option to fetch the raw message

razorsmith commented 11 years ago

Great job Tim...that worked a treat. Slick change. Thx

timkay commented 11 years ago

jberryman, the change was to not encode most of the characters. Instead, it encodes only a few that would cause it to break otherwise.