diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2008-01-18 17:32:55 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2008-01-18 17:32:55 +0000 |
| commit | e4341def77be591ea5be66a0b7ccbe3d69f225b6 (patch) | |
| tree | 9fce5fd72b6ef63f9d222b221597b8a12fc7529f | |
| parent | 7e5c60146c7d7e80368edbf005dbaa06eed787a5 (diff) | |
| download | qpid-python-e4341def77be591ea5be66a0b7ccbe3d69f225b6.tar.gz | |
fixed python dependence on the content-length attribute (bz 419371)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@613211 13f79535-47bb-0310-9956-ffa450edef68
| -rw-r--r-- | qpid/python/qpid/connection.py | 10 | ||||
| -rw-r--r-- | qpid/python/qpid/peer.py | 12 | ||||
| -rw-r--r-- | qpid/python/tests_0-10/message.py | 19 |
3 files changed, 30 insertions, 11 deletions
diff --git a/qpid/python/qpid/connection.py b/qpid/python/qpid/connection.py index 1beb60822d..ecbce295b7 100644 --- a/qpid/python/qpid/connection.py +++ b/qpid/python/qpid/connection.py @@ -360,7 +360,8 @@ class Header(Frame): # message properties store the content-length now, and weight is # deprecated - structs[1].content_length = self.size + if self.size != None: + structs[1].content_length = self.size for s in structs: c.encode_long_struct(s) @@ -412,9 +413,10 @@ class Header(Frame): length = None for s in structs: for f in s.type.fields: - props[f.name] = s.get(f.name) - if f.name == "content_length": - length = s.get(f.name) + if s.has(f.name): + props[f.name] = s.get(f.name) + if f.name == "content_length": + length = s.get(f.name) return Header(None, 0, length, props) @staticmethod diff --git a/qpid/python/qpid/peer.py b/qpid/python/qpid/peer.py index 376d81e184..c7f56b49b2 100644 --- a/qpid/python/qpid/peer.py +++ b/qpid/python/qpid/peer.py @@ -226,13 +226,12 @@ class Channel: self.write_content(frame.method_type.klass, content) def write_content(self, klass, content): - size = content.size() - header = Header(klass, content.weight(), size, content.properties) + header = Header(klass, content.weight(), content.size(), content.properties) self.write(header) for child in content.children: self.write_content(klass, child) # should split up if content.body exceeds max frame size - if size > 0: + if content.body: self.write(Body(content.body)) def receive(self, frame, work): @@ -360,14 +359,13 @@ def read_content(queue): children = [] for i in range(header.weight): children.append(read_content(queue)) - size = header.size - read = 0 buf = StringIO() - while read < size: + eof = header.eof + while not eof: body = queue.get() + eof = body.eof content = body.content buf.write(content) - read += len(content) return Content(buf.getvalue(), children, header.properties.copy()) class Future: diff --git a/qpid/python/tests_0-10/message.py b/qpid/python/tests_0-10/message.py index 1daaad9ba1..9ec1cc270c 100644 --- a/qpid/python/tests_0-10/message.py +++ b/qpid/python/tests_0-10/message.py @@ -720,6 +720,20 @@ class MessageTests(TestBase): #check all 'browsed' messages are still on the queue self.assertEqual(5, channel.queue_query(queue="q").message_count) + def test_no_size(self): + self.queue_declare(queue = "q", exclusive=True, auto_delete=True) + + ch = self.channel + ch.message_transfer(content=SizelessContent(properties={'routing_key' : "q"}, body="message-body")) + + ch.message_subscribe(queue = "q", destination="d", confirm_mode = 0) + ch.message_flow(unit = 0, value = 0xFFFFFFFF, destination = "d") + ch.message_flow(unit = 1, value = 0xFFFFFFFF, destination = "d") + + queue = self.client.queue("d") + msg = queue.get(timeout = 3) + self.assertEquals("message-body", msg.content.body) + def assertDataEquals(self, channel, msg, expected): self.assertEquals(expected, msg.content.body) @@ -728,3 +742,8 @@ class MessageTests(TestBase): extra = queue.get(timeout=1) self.fail("Queue not empty, contains: " + extra.content.body) except Empty: None + +class SizelessContent(Content): + + def size(self): + return None |
