Issue #175 resolved

utils.Mimer.translate_mime() doesn't handle the jQuery.post() right.

wxiluo
created an issue

CONTENT_TYPE of jQuery.post() POST request is "application/x-www-form-urlencoded; charset=UTF-8". Piston only work with "application/x-www-form-urlencoded".

It's very bad.

Comments (5)

  1. Stephan Klein

    I stand corrected, it seems that this issue has been resolved in trunk.

    The lastest source in c4b2d21db51a uses

    if type_formencoded in ctype:
    

    which solves the issue.

    For anyone forced to use an older version of piston, I would recommend overriding the Resource class with something like this:

    import piston.utils
    from piston import Resrouce
    
    class MyResource(Resource):
      if piston.utils.__version__ <= "0.2.2":
        def __call__(self, request, *args, **kwargs):
          if request.META["CONTENT_TYPE"].startswith("application/x-www-form-urlencoded"):
            request.META["CONTENT_TYPE"] = "application/x-www-form-urlencoded"
          return super(MyResource, self).__call__(request, *args, **kwargs)
    
  2. Log in to comment