You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Rajith Attapattu <ra...@gmail.com> on 2009/12/01 01:17:31 UTC

Interop issue btw Java and new python client

Hi,

A minor interop issue happens due to the java "test/plain" content
type not being handled properly in the new python client API.
The python client expects the encoding along with the content type,
while the java client just specifies the content type.

The following patch is a workaround.
The patch defaults to utf8 if the charset is not specified for content
type "text/plain".
However not not sure if it's the right solution.

Index: qpid/messaging.py
===================================================================
--- qpid/messaging.py	(revision 885604)
+++ qpid/messaging.py	(working copy)
@@ -716,6 +716,7 @@
   dict: "amqp/map",
   list: "amqp/list",
   unicode: "text/plain; charset=utf8",
+  unicode: "text/plain",
   buffer: None,
   str: None,
   None.__class__: None
@@ -725,6 +726,7 @@
   "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")),
   "": (lambda x: x, lambda x: x),
   None: (lambda x: x, lambda x: x)
   }



Regards,

Rajith Attapattu
Red Hat
http://rajith.2rlabs.com/

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org


Re: Interop issue btw Java and new python client

Posted by Rafael Schloming <ra...@redhat.com>.
Rajith Attapattu wrote:
> Hi,
> 
> A minor interop issue happens due to the java "test/plain" content
> type not being handled properly in the new python client API.
> The python client expects the encoding along with the content type,
> while the java client just specifies the content type.
> 
> The following patch is a workaround.
> The patch defaults to utf8 if the charset is not specified for content
> type "text/plain".
> However not not sure if it's the right solution.

Good catch. I think I need to make the lookup process a bit smarter so 
that it a) properly parses content types rather than doing a simple 
lookup, and b) takes into account the value of the content-encoding header.

This does leave open the question of what to do when the value specified 
in the mime type and the content-encoding header don't actually match.

Feel free to commit the workaround. I'll add the more complete fix to my 
todo list.

--Rafael


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org