]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Tweak default source of query a bit so it is possible to invoke
authorGuido van Rossum <guido@python.org>
Wed, 28 May 1997 15:39:15 +0000 (15:39 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 28 May 1997 15:39:15 +0000 (15:39 +0000)
a CGI script from the command line with not environment variables.

Lib/cgi.py

index 6c31f7428d5bd8f84f016fc2fb3652d29c5e68fa..20f4700d7a3583caf04ea06e46ac3fe329807442 100755 (executable)
@@ -783,17 +783,20 @@ class FieldStorage:
            If true, errors raise a ValueError exception.
 
        """
-       method = None
+       method = 'GET'
        self.keep_blank_values = keep_blank_values
        self.strict_parsing = strict_parsing
        if environ.has_key('REQUEST_METHOD'):
            method = string.upper(environ['REQUEST_METHOD'])
        if not fp and method == 'GET':
-           qs = None
            if environ.has_key('QUERY_STRING'):
                qs = environ['QUERY_STRING']
+           elif sys.argv[1:]:
+               qs = sys.argv[1]
+           else:
+               qs = ""
            from StringIO import StringIO
-           fp = StringIO(qs or "")
+           fp = StringIO(qs)
            if headers is None:
                headers = {'content-type':
                           "application/x-www-form-urlencoded"}