From b43036056e0dc7ad8fb919bd1f5b065ff01502c5 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Fri, 18 Jan 2008 17:32:55 +0000 Subject: fixed python dependence on the content-length attribute (bz 419371) git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@613211 13f79535-47bb-0310-9956-ffa450edef68 --- python/qpid/connection.py | 10 ++++++---- python/qpid/peer.py | 12 +++++------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'python/qpid') diff --git a/python/qpid/connection.py b/python/qpid/connection.py index 1beb60822d..ecbce295b7 100644 --- a/python/qpid/connection.py +++ b/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/python/qpid/peer.py b/python/qpid/peer.py index 376d81e184..c7f56b49b2 100644 --- a/python/qpid/peer.py +++ b/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: -- cgit v1.2.1