Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#677 closed defect (fixed)

JsonService should provide different content-type --- Single line fix

Reported by: spamcatcher@… Owned by: anonymous
Priority: high Milestone:
Component: General Version:
Keywords: json jsonserver rpc content-type Cc:
Blocked by: Blocking:

Description

The request content-type that is POSTed as a result of a JsonService.bind is "application/x-www-form-urlencoded" which is the default value for a POST in BrowserIO.js when kwArgs.contentType is not set.

There is no official standard for the content-type for a json rpc request yet, but the jsonserver folks will be asking for "application/json-rpc". Jsonserver ( http://zif.hill-street.net/jsonserver ) in zope3 requires that the content-type be set to "application/json-rpc" for the server to handle it differently than an ordinary http POST operation. A single line added to the bind method in jsonService.js will allow dojo to work out-of-the-box with jsonserver in zope3.

src/rpc/JsonService.js:

   bind: function(method, parameters, deferredRequestHandler, url){
      dojo.io.bind({
         url: url||this.serviceUrl,
         postContent: this.createRequest(method, parameters),
         method: "POST",
         mimetype: "text/json",

         // ****  Add the following line ****
         contentType: "application/json-rpc", 

         load: this.resultCallback(deferredRequestHandler),
         preventCache:this.bustCache 
      });
   },

There was a previous ticket #503, recently marked wontfix that tried to address this issue, but the discussion got tangled in issues of mimetype, which is not relevant.

If you do not wish to set this content-type as a default, there probably should be a way to pass in a content-type in the dojo.rpc.JsonService constructor.

Change History (2)

comment:1 Changed 8 years ago by sjmiles

  • Resolution set to fixed
  • Status changed from new to closed

Added contentType property (used for the bind content-type) to JSONRpcService with default value "application/json-rpc" see r3842

comment:2 Changed 7 years ago by anonymous

  • Milestone 0.3release deleted

Milestone 0.3release deleted

Note: See TracTickets for help on using tickets.