diff roundup/cgi/wsgi_handler.py @ 4292:859ab007829f

Handle OPTIONS http request method in wsgi handler, fixes issue2550587. Thanks to Thomas Arendsen Hein for reporting and to Intevation for funding the fix.
author Ralf Schlatterbeck <schlatterbeck@users.sourceforge.net>
date Tue, 01 Dec 2009 09:09:11 +0000
parents 0728808fdf5c
children 7aa72c31464d
line wrap: on
line diff
--- a/roundup/cgi/wsgi_handler.py	Mon Nov 30 21:55:59 2009 +0000
+++ b/roundup/cgi/wsgi_handler.py	Tue Dec 01 09:09:11 2009 +0000
@@ -10,7 +10,7 @@
 
 import roundup.instance
 from roundup.cgi import TranslationService
-from BaseHTTPServer import BaseHTTPRequestHandler
+from BaseHTTPServer import BaseHTTPRequestHandler, DEFAULT_ERROR_MESSAGE
 
 
 class Writer(object):
@@ -43,6 +43,14 @@
         request.wfile = Writer(request)
         request.__wfile = None
 
+        if environ ['REQUEST_METHOD'] == 'OPTIONS':
+            code = 501
+            message, explain = BaseHTTPRequestHandler.responses[code]
+            request.start_response([('Content-Type', 'text/html'),
+                ('Connection', 'close')], code)
+            request.wfile.write(DEFAULT_ERROR_MESSAGE % locals())
+            return []
+
         tracker = roundup.instance.open(self.home, not self.debug)
 
         # need to strip the leading '/'

Roundup Issue Tracker: http://roundup-tracker.org/