comparison roundup/cgi/client.py @ 5608:5df309febe49

Path to support OPTIONS verb when using rest interface via roundup-server. Also make sure rest interface doesn't hang when processing OPTIONS, DELETE, PATCH which don't have a payload by creating a CONTENT_LENGTH of 0 if these verbs are used and CONTENT_LENGTH is missing.
author John Rouillard <rouilj@ieee.org>
date Fri, 08 Feb 2019 19:39:17 -0500
parents 79da1ca2f94b
children 0a8f0fddc2ae be99aa02c616
comparison
equal deleted inserted replaced
5606:5fc476d4e34c 5608:5df309febe49
361 # nonces for scripts. 361 # nonces for scripts.
362 self.client_nonce = self._gen_nonce() 362 self.client_nonce = self._gen_nonce()
363 363
364 # see if we need to re-parse the environment for the form (eg Zope) 364 # see if we need to re-parse the environment for the form (eg Zope)
365 if form is None: 365 if form is None:
366 # cgi.FieldStorage doesn't special case OPTIONS, DELETE or
367 # PATCH verbs. They are processed like POST. So FieldStorage
368 # hangs on these verbs trying to read posted data that
369 # will never arrive.
370 # If not defined, set CONTENT_LENGTH to 0 so it doesn't
371 # hang reading the data.
372 if self.env['REQUEST_METHOD'] in ['OPTIONS', 'DELETE', 'PATCH']:
373 if 'CONTENT_LENGTH' not in self.env:
374 self.env['CONTENT_LENGTH'] = 0
375 logger.debug("Setting CONTENT_LENGTH to 0 for method: %s",
376 self.env['REQUEST_METHOD'])
377
366 self.form = cgi.FieldStorage(fp=request.rfile, environ=env) 378 self.form = cgi.FieldStorage(fp=request.rfile, environ=env)
367 # In some case (e.g. content-type application/xml), cgi 379 # In some case (e.g. content-type application/xml), cgi
368 # will not parse anything. Fake a list property in this case 380 # will not parse anything. Fake a list property in this case
369 if self.form.list is None: 381 if self.form.list is None:
370 self.form.list = [] 382 self.form.list = []

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