From bbde6abeab77d2ee7ae283d82709f904e1a1fb71 Mon Sep 17 00:00:00 2001 From: schlatterbeck Date: Tue, 1 Dec 2009 09:09:11 +0000 Subject: [PATCH] Handle OPTIONS http request method in wsgi handler, fixes issue2550587. Thanks to Thomas Arendsen Hein for reporting and to Intevation for funding the fix. git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4396 57a73879-2fb5-44c3-a270-3262357dd7e2 --- CHANGES.txt | 7 +++++-- roundup/cgi/wsgi_handler.py | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 6c85c17..d219cdd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -23,8 +23,11 @@ Fixes: fix. - Fix traceback on .../msgN/ url, this requests the file content and for apache mod_wsgi produced a traceback because the mime type is None for - messages, fixes issue2550586, thanks to ThomasAH for reporting and to - Intevation for funding the fix. + messages, fixes issue2550586, thanks to Thomas Arendsen Hein for + reporting and to Intevation for funding the fix. +- Handle OPTIONS http request method in wsgi handler, fixes issue2550587. + Thanks to Thomas Arendsen Hein for reporting and to Intevation for + funding the fix. 2009-10-09 1.4.10 (r4374) diff --git a/roundup/cgi/wsgi_handler.py b/roundup/cgi/wsgi_handler.py index 3415d8c..27bc890 100644 --- a/roundup/cgi/wsgi_handler.py +++ b/roundup/cgi/wsgi_handler.py @@ -10,7 +10,7 @@ import weakref 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 @@ class RequestDispatcher(object): 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 '/' -- 2.30.2