diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2010-07-12 13:43:27 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2010-07-12 13:43:27 +0000 |
| commit | ab590f872ef0c901b955b2ed4c773403d946d9ad (patch) | |
| tree | aeccc3b24b48bf46c045711ed238e7b653ecb4f2 /qpid/python | |
| parent | dc064352b920a9ca85d86063b094a50ab02dc213 (diff) | |
| download | qpid-python-ab590f872ef0c901b955b2ed4c773403d946d9ad.tar.gz | |
fixed payload of None for text/plain messages
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@963280 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python')
| -rw-r--r-- | qpid/python/qpid/messaging/message.py | 16 | ||||
| -rw-r--r-- | qpid/python/qpid/tests/messaging/message.py | 6 |
2 files changed, 20 insertions, 2 deletions
diff --git a/qpid/python/qpid/messaging/message.py b/qpid/python/qpid/messaging/message.py index e2406f16e7..b70b365c16 100644 --- a/qpid/python/qpid/messaging/message.py +++ b/qpid/python/qpid/messaging/message.py @@ -49,11 +49,23 @@ TYPE_MAPPINGS={ DEFAULT_CODEC = (lambda x: x, lambda x: x) +def encode_text_plain(x): + if x is None: + return None + else: + return x.encode("utf8") + +def decode_text_plain(x): + if x is None: + return None + else: + return x.decode("utf8") + TYPE_CODEC={ "amqp/map": codec("map"), "amqp/list": codec("list"), - "text/plain; charset=utf8": (lambda x: x.encode("utf8"), lambda x: x.decode("utf8")), - "text/plain": (lambda x: x.encode("utf8"), lambda x: x.decode("utf8")), + "text/plain; charset=utf8": (encode_text_plain, decode_text_plain), + "text/plain": (encode_text_plain, decode_text_plain), "": DEFAULT_CODEC, None: DEFAULT_CODEC } diff --git a/qpid/python/qpid/tests/messaging/message.py b/qpid/python/qpid/tests/messaging/message.py index 91aab5fb35..526a5cfab6 100644 --- a/qpid/python/qpid/tests/messaging/message.py +++ b/qpid/python/qpid/tests/messaging/message.py @@ -111,3 +111,9 @@ class MessageEchoTests(Base): def testContentTypeUnknown(self): msg = Message(content_type = "this-content-type-does-not-exist") self.check(msg) + + def testTextPlain(self): + self.check(Message(content_type="text/plain", content="asdf")) + + def testTextPlainEmpty(self): + self.check(Message(content_type="text/plain")) |
