samuraisam / django-json-rpc

JSON-RPC Implementation for Django
MIT License
286 stars 83 forks source link

Can't do a GET with JsonRPC like : http://.../jsonrpc/app.trimTails?{...} #15

Open stphdenis opened 14 years ago

stphdenis commented 14 years ago

When using DojoToolkit we can have things like : http://.../jsonrpc/app.trimTails?{"id":"0", "method":"app.trimTails", "params":{"nom":"iuhoi"}, "jsonrpc":"2.0"}

Like it does not work with django-json-rpc I have modified the validate_get method of site.py in my sources as :

if request.method == 'GET':
  method = unicode(method)
  if method in self.urls and getattr(self.urls[method], 'json_safe', False):
    #### sd 2010/03/31 ## BEGIN ##
    params = request.GET.lists()
    if len(params) == 1 and len(params[0]) == 2:
      k = params[0][0]
      if k[0] == '{':
        try:
          D = loads(k)
          return True, D
        except:
          pass
    D = {
      'params': encode_get_params(params),
    # 'params': encode_get_params(request.GET.lists()),
    #### modif sd ## END ##
      'method': method,
      'id': 'jsonrpc',
      'version': '1.1'
    }
    return True, D
return False, {}

If it can help...

samuraisam commented 14 years ago

How common is this style of GET RPC? I don't see its support in the spec.

Only 1.1 supports HTTP GET and its intended use is for idempotent, safe methods which work well with HTTP GET.

samuraisam commented 13 years ago

Please write this as a pull request and I can merge it.