Issue #83 open

Use X-HTTP-Method-Override to override PUT and DELETE

Zhigang Wang
created an issue

hi jespern,

Can we consider implementing the X-HTTP-Method-Override mechnism?

see: http://code.google.com/apis/gdata/docs/2.0/basics.html

As I searched, most libraries haven't support http PUT/DELETE yet.

Thanks for the excellent work. I find this library fits best the REST concept.

thanks,

zhigang

Comments (5)

  1. Jesper Nøhr repo owner
    • changed status to open

    Hi Zhigang,

    Sure, that's reasonable. Someone has earlier suggested overriding methods with _method={PUT,DELETE} in the URL, which is awful. I can agree to X-HTTP-Method-Override.

    Do you feel like implementing it yourself?

  2. ablerman

    I'm using some middleware to take care of this. Something like:

    class x_http_methodoverride_middleware():
        def process_request(self, request):
            if 'HTTP_X_HTTP_METHODOVERRIDE' in request.META:
                newMethod = request.META['HTTP_X_HTTP_METHODOVERRIDE']
                if 'PUT' == newMethod.upper():
                    request.method = 'PUT'
                    request.META['REQUEST_METHOD'] = 'PUT'
                    request.PUT = request.POST                
                if 'DELETE' == newMethod.upper() or 'DEL' == newMethod.upper():
                    request.method = 'DELETE'
                    request.META['REQUEST_METHOD'] = 'DELETE'
                    request.DELETE = request.POST
    
  3. Log in to comment