Skip to content

Instantly share code, notes, and snippets.

@jacobian
Created July 28, 2012 19:55
Show Gist options
  • Save jacobian/3194551 to your computer and use it in GitHub Desktop.
Save jacobian/3194551 to your computer and use it in GitHub Desktop.
class PatchMethodOverrideMiddleware(object):
"""
Support X-HTTP-Method-Override: PATCH.
This isn't 100% support, since it's just here to work around ELB
not supporting PATCH. So this only allows "converting" POST to PATCH.
"""
def process_request(self, request):
if request.method == 'POST':
override = request.META.pop('HTTP_X_HTTP_METHOD_OVERRIDE', '')
if override.upper() == 'PATCH':
request.method = 'PATCH'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment