comparison 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
comparison
equal deleted inserted replaced
4291:b1772fdb09d0 4292:859ab007829f
8 import cgi 8 import cgi
9 import weakref 9 import weakref
10 10
11 import roundup.instance 11 import roundup.instance
12 from roundup.cgi import TranslationService 12 from roundup.cgi import TranslationService
13 from BaseHTTPServer import BaseHTTPRequestHandler 13 from BaseHTTPServer import BaseHTTPRequestHandler, DEFAULT_ERROR_MESSAGE
14 14
15 15
16 class Writer(object): 16 class Writer(object):
17 '''Perform a start_response if need be when we start writing.''' 17 '''Perform a start_response if need be when we start writing.'''
18 def __init__(self, request): 18 def __init__(self, request):
41 request.__start_response = start_response 41 request.__start_response = start_response
42 42
43 request.wfile = Writer(request) 43 request.wfile = Writer(request)
44 request.__wfile = None 44 request.__wfile = None
45 45
46 if environ ['REQUEST_METHOD'] == 'OPTIONS':
47 code = 501
48 message, explain = BaseHTTPRequestHandler.responses[code]
49 request.start_response([('Content-Type', 'text/html'),
50 ('Connection', 'close')], code)
51 request.wfile.write(DEFAULT_ERROR_MESSAGE % locals())
52 return []
53
46 tracker = roundup.instance.open(self.home, not self.debug) 54 tracker = roundup.instance.open(self.home, not self.debug)
47 55
48 # need to strip the leading '/' 56 # need to strip the leading '/'
49 environ["PATH_INFO"] = environ["PATH_INFO"][1:] 57 environ["PATH_INFO"] = environ["PATH_INFO"][1:]
50 if request.timing: 58 if request.timing:

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