[Zope3-Users] z3c.jsonrpc response content type bug

2008-10-28 Thread Yuan HOng
When I use z3c.jsonrpc (svn head) to publish an object, the response
generated gets the content header:

Content-Type: application/x-javascript

According to the README.txt of the package:

This project provides the proposed request type application/json. The request
type application/json-rpc is supported as long it is not officialy deprecated.

And it also expects to receive a request with 'application/json'
header. So this should be a bug.

To fix it, one just need to modify _prepareResult method in the file
publisher.py to change from

# set content type
self.setHeader('content-type', application/x-javascript;charset=%s \
% charset)

to

# set content type
self.setHeader('content-type', application/json;charset=%s \
% charset)


-- 
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.jsonrpc response content type bug

2008-10-28 Thread Roger Ineichen
Hi Yuan

 Betreff: [Zope3-Users] z3c.jsonrpc response content type bug
 
 When I use z3c.jsonrpc (svn head) to publish an object, the 
 response generated gets the content header:
 
 Content-Type: application/x-javascript
 
 According to the README.txt of the package:
 
 This project provides the proposed request type 
 application/json. The request type application/json-rpc 
 is supported as long it is not officialy deprecated.
 
 And it also expects to receive a request with 'application/json'
 header. So this should be a bug.
 
 To fix it, one just need to modify _prepareResult method in 
 the file publisher.py to change from
 
 # set content type
 self.setHeader('content-type', 
 application/x-javascript;charset=%s \
 % charset)
 
 to
 
 # set content type
 self.setHeader('content-type', application/json;charset=%s \
 % charset)
 --
 Hong Yuan

Thanks for the hint. I'll take a look at that this week.
Regards
Roger Ineichen
_
END OF MESSAGE

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.jsonrpc response content type bug

2008-10-28 Thread Jim Washington
Roger Ineichen wrote:
 Hi Yuan
 
 Betreff: [Zope3-Users] z3c.jsonrpc response content type bug

 When I use z3c.jsonrpc (svn head) to publish an object, the 
 response generated gets the content header:

 Content-Type: application/x-javascript

 According to the README.txt of the package:

 This project provides the proposed request type 
 application/json. The request type application/json-rpc 
 is supported as long it is not officialy deprecated.

 And it also expects to receive a request with 'application/json'
 header. So this should be a bug.

 To fix it, one just need to modify _prepareResult method in 
 the file publisher.py to change from

 # set content type
 self.setHeader('content-type', 
 application/x-javascript;charset=%s \
 % charset)

 to

 # set content type
 self.setHeader('content-type', application/json;charset=%s \
 % charset)
 --
 Hong Yuan
 
 Thanks for the hint. I'll take a look at that this week.
 Regards
 Roger Ineichen

A bit of history on this.  The content-type in this bit of code was
determined more than three years ago by testing with several old major
web browsers.  At the time, 'application/x-javascript' was the
content-type that reliably told the web browser to use its javascript
parser on the document so that the rpc data could be used.  Other
settings did not work on all of the web browsers I tested.

So, this content-type was decided empirically (a long time ago), not
from specification. It maybe should continue to be the default for
compatibility with creaky old web browsers.  But maybe it can be
changeable (if you *really* know what you are doing) so that the
outgoing document can meet the expectations of client libraries.

- Jim Washington

___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


Re: [Zope3-Users] z3c.jsonrpc response content type bug

2008-10-28 Thread Yuan HOng
On Tue, Oct 28, 2008 at 6:32 PM, Jim Washington [EMAIL PROTECTED] wrote:

 A bit of history on this.  The content-type in this bit of code was
 determined more than three years ago by testing with several old major
 web browsers.  At the time, 'application/x-javascript' was the
 content-type that reliably told the web browser to use its javascript
 parser on the document so that the rpc data could be used.  Other
 settings did not work on all of the web browsers I tested.

 So, this content-type was decided empirically (a long time ago), not
 from specification. It maybe should continue to be the default for
 compatibility with creaky old web browsers.  But maybe it can be
 changeable (if you *really* know what you are doing) so that the
 outgoing document can meet the expectations of client libraries.

 - Jim Washington



Reasonable. Then it would be nice to add a configuration directive so
that user can set the content-type based on the requirement of client
libraries.

For me, I am using IE6, IE7, FF2 and FF3 with the ExtJS library and
applicatin/json works fine.

-- 
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users