mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Tweak default source of query a bit so it is possible to invoke
a CGI script from the command line with not environment variables.
This commit is contained in:
parent
1aec3f087e
commit
d7c9d96d3e
1 changed files with 6 additions and 3 deletions
|
@ -783,17 +783,20 @@ class FieldStorage:
|
||||||
If true, errors raise a ValueError exception.
|
If true, errors raise a ValueError exception.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
method = None
|
method = 'GET'
|
||||||
self.keep_blank_values = keep_blank_values
|
self.keep_blank_values = keep_blank_values
|
||||||
self.strict_parsing = strict_parsing
|
self.strict_parsing = strict_parsing
|
||||||
if environ.has_key('REQUEST_METHOD'):
|
if environ.has_key('REQUEST_METHOD'):
|
||||||
method = string.upper(environ['REQUEST_METHOD'])
|
method = string.upper(environ['REQUEST_METHOD'])
|
||||||
if not fp and method == 'GET':
|
if not fp and method == 'GET':
|
||||||
qs = None
|
|
||||||
if environ.has_key('QUERY_STRING'):
|
if environ.has_key('QUERY_STRING'):
|
||||||
qs = environ['QUERY_STRING']
|
qs = environ['QUERY_STRING']
|
||||||
|
elif sys.argv[1:]:
|
||||||
|
qs = sys.argv[1]
|
||||||
|
else:
|
||||||
|
qs = ""
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
fp = StringIO(qs or "")
|
fp = StringIO(qs)
|
||||||
if headers is None:
|
if headers is None:
|
||||||
headers = {'content-type':
|
headers = {'content-type':
|
||||||
"application/x-www-form-urlencoded"}
|
"application/x-www-form-urlencoded"}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue