src/ldt/ldt/api/middleware/pistonput.py
changeset 332 c28d4dc49a50
child 1190 129d45eec68c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/ldt/ldt/api/middleware/pistonput.py	Thu Jan 05 17:41:27 2012 +0100
@@ -0,0 +1,18 @@
+"""
+This middleware changes the request header content type because 
+piston does not like 'charset=UTF-8" in PUT request
+"""
+
+from django.conf import settings
+
+class PistonPutMiddleware(object):
+
+    def process_request(self, request):
+        if request.method in ('PUT') and not 'boundary=' in request.META['CONTENT_TYPE']:
+            request.META['CONTENT_TYPE'] = [c.strip() for c in request.META['CONTENT_TYPE'].split(";") ][0]
+        return None
+#        if request.method == 'PUT' and request.META.has_key('CONTENT_TYPE') :
+#            if request.META['CONTENT_TYPE'] == 'application/x-www-form-urlencoded; charset=UTF-8':
+#                request.META['CONTENT_TYPE'] = 'application/x-www-form-urlencoded'
+#            if request.META['CONTENT_TYPE'] == 'application/json; charset=UTF-8':
+#                request.META['CONTENT_TYPE'] = 'application/json'
\ No newline at end of file