Cleanup SQS body encoding. Closes #458, #460.

This commit is contained in:
Steve Pulec 2017-03-19 11:03:22 -04:00
parent f9b7a0a539
commit a0a205328d
2 changed files with 17 additions and 1 deletions

View File

@ -125,6 +125,7 @@ class BaseResponse(_TemplateEnvironmentMixin):
for key, value in request.form.items():
querystring[key] = [value, ]
raw_body = self.body
if isinstance(self.body, six.binary_type):
self.body = self.body.decode('utf-8')
@ -143,7 +144,7 @@ class BaseResponse(_TemplateEnvironmentMixin):
for key, value in flat.items():
querystring[key] = [value]
elif self.body:
querystring.update(parse_qs(self.body, keep_blank_values=True))
querystring.update(parse_qs(raw_body, keep_blank_values=True))
if not querystring:
querystring.update(headers)

View File

@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import boto
@ -54,6 +55,20 @@ def test_message_send():
messages.should.have.length_of(1)
@mock_sqs
def test_send_message_with_unicode_characters():
body_one = 'Héllo!😀'
sqs = boto3.resource('sqs', region_name='us-east-1')
queue = sqs.create_queue(QueueName="blah")
msg = queue.send_message(MessageBody=body_one)
messages = queue.receive_messages()
message_body = messages[0].body
message_body.should.equal(body_one)
@mock_sqs
def test_set_queue_attributes():
sqs = boto3.resource('sqs', region_name='us-east-1')