From: Mark Wooding Date: Sat, 13 Jul 2013 15:34:40 +0000 (+0100) Subject: cgi.py: Export request method from `cgiparse'. X-Git-Tag: 1.0.3~4 X-Git-Url: https://git.distorted.org.uk/~mdw/chopwood/commitdiff_plain/f2e194ee85b9538d5168fe776e1cdbc00ce8ca9d cgi.py: Export request method from `cgiparse'. We'll want to know it later. --- diff --git a/cgi.py b/cgi.py index d66bfc6..1aa2917 100644 --- a/cgi.py +++ b/cgi.py @@ -311,6 +311,7 @@ def cgi_errors(hook = None): ### CGI input. ## Lots of global variables to be filled in by `cgiparse'. +METHOD = None COOKIE = {} SPECIAL = {} PARAM = [] @@ -377,20 +378,20 @@ def cgiparse(): True if the client connection is carried over SSL or TLS. """ - global SSLP + global METHOD, SSLP def getenv(var): try: return ENV[var] except KeyError: raise U.ExpectedError, (500, "No `%s' supplied" % var) ## Yes, we want the request method. - method = getenv('REQUEST_METHOD') + METHOD = getenv('REQUEST_METHOD') ## Acquire the query string. - if method == 'GET': + if METHOD == 'GET': q = getenv('QUERY_STRING') - elif method == 'POST': + elif METHOD == 'POST': ## We must read the query string from stdin. n = getenv('CONTENT_LENGTH') @@ -404,7 +405,7 @@ def cgiparse(): raise U.ExpectedError, (500, "Failed to read correct length") else: - raise U.ExpectedError, (500, "Unexpected request method `%s'" % method) + raise U.ExpectedError, (500, "Unexpected request method `%s'" % METHOD) ## Populate the `SPECIAL', `PARAM' and `PARAMDICT' tables. seen = set()