yuwei5380 / jsonplugin

Automatically exported from code.google.com/p/jsonplugin
0 stars 0 forks source link

Can you add support for dojo rpc service with content-type like "application/json-rpc; charset=UTF-8"? #59

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Using Dojo Service code like bellow:
<script type="text/javascript">
    //load dojo RPC
    dojo.require("dojo.rpc.JsonService");
    dojo.require("dijit.form.Button");
    //create service object(proxy) using SMD (generated by the json result)
    var service = new dojo.rpc.JsonService("${smdUrl}");

    function sendsmd(){
        //parameter
        var bean = {type: "Mocca"};

        //execute remote method
        console.dir(service);
        var defered = service.doSomething(bean, 5);

        //attach callback to defered object
        defered.addCallback(callback);
    }

    //function called when remote method returns
    var callback = function(bean) {
        alert("Price for " + bean.type + " is " + bean.price);
    };

</script>
<div dojoType="dijit.form.Button" onclick="sendsmd();">Send SMB</div>

It send SMD call but with content type like:
...
User-Agent  Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.9.0.1)
Gecko/2008070206 Firefox/3.0.1
Accept  text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language zh-cn,zh;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset  gb2312,utf-8;q=0.7,*;q=0.7
Keep-Alive  300
Connection  keep-alive
Content-Type    application/json-rpc; charset=UTF-8
X-Requested-With    XMLHttpRequest
Referer http://localhost:8080/webflow/showClock.html
Content-Length  61
...

2. Jsonplugin report it was not a right SMD request:
DEBUG - JSONInterceptor.intercept(137) | Content type must be
'application/json' or 'application/json-rpc'. Ignoring request with content
type application/x-www-form-urlencoded

3. I checked the code, it becuase:

if ((contentType != null) &&
contentType..equalsIgnoreCase("application/json-rpc")) {

change it to support charset will make it work as bellow,

contentType.toLowerCase().contains("application/json-rpc").

What is the expected output? What do you see instead?
I don't know if application/json-rpc; charset=UTF-8 if a right SMD request,
but I think support charset field is good choice for us, how about to add a
charset fileld support for contentType?

What version of the product are you using? On what operating system?
Dojo Version:1.1.0
JsonPluging: 0.30

Please provide any additional information below.
Thanks 
-Santal Li

Original issue reported on code.google.com by Santal...@gmail.com on 26 Aug 2008 at 4:13

GoogleCodeExporter commented 8 years ago
I am using Fedora C8 as the develop machine and Firefox3 as web browser.

Original comment by Santal...@gmail.com on 26 Aug 2008 at 4:14

GoogleCodeExporter commented 8 years ago
Seems already resolve in 0.31, It work well now.

Original comment by Santal...@gmail.com on 27 Aug 2008 at 8:36

GoogleCodeExporter commented 8 years ago

Original comment by musa...@gmail.com on 21 Oct 2008 at 2:30