Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/wsgicgi.py @ 34512:482d6f6dba91
hgweb: when constructing or adding to a wsgi environ dict, use native strs
That's what's required of us to work with the WSGI API on Python 3.
Differential Revision: https://phab.mercurial-scm.org/D967
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 05 Oct 2017 14:22:02 -0400 |
parents | a57c938e7ac8 |
children | d4a2e0d5d042 |
comparison
equal
deleted
inserted
replaced
34511:67873ec0f4ce | 34512:482d6f6dba91 |
---|---|
22 def launch(application): | 22 def launch(application): |
23 util.setbinary(util.stdin) | 23 util.setbinary(util.stdin) |
24 util.setbinary(util.stdout) | 24 util.setbinary(util.stdout) |
25 | 25 |
26 environ = dict(encoding.environ.iteritems()) | 26 environ = dict(encoding.environ.iteritems()) |
27 environ.setdefault('PATH_INFO', '') | 27 environ.setdefault(r'PATH_INFO', '') |
28 if environ.get('SERVER_SOFTWARE', '').startswith('Microsoft-IIS'): | 28 if environ.get(r'SERVER_SOFTWARE', r'').startswith(r'Microsoft-IIS'): |
29 # IIS includes script_name in PATH_INFO | 29 # IIS includes script_name in PATH_INFO |
30 scriptname = environ['SCRIPT_NAME'] | 30 scriptname = environ[r'SCRIPT_NAME'] |
31 if environ['PATH_INFO'].startswith(scriptname): | 31 if environ[r'PATH_INFO'].startswith(scriptname): |
32 environ['PATH_INFO'] = environ['PATH_INFO'][len(scriptname):] | 32 environ[r'PATH_INFO'] = environ[r'PATH_INFO'][len(scriptname):] |
33 | 33 |
34 stdin = util.stdin | 34 stdin = util.stdin |
35 if environ.get('HTTP_EXPECT', '').lower() == '100-continue': | 35 if environ.get(r'HTTP_EXPECT', r'').lower() == r'100-continue': |
36 stdin = common.continuereader(stdin, util.stdout.write) | 36 stdin = common.continuereader(stdin, util.stdout.write) |
37 | 37 |
38 environ['wsgi.input'] = stdin | 38 environ[r'wsgi.input'] = stdin |
39 environ['wsgi.errors'] = util.stderr | 39 environ[r'wsgi.errors'] = util.stderr |
40 environ['wsgi.version'] = (1, 0) | 40 environ[r'wsgi.version'] = (1, 0) |
41 environ['wsgi.multithread'] = False | 41 environ[r'wsgi.multithread'] = False |
42 environ['wsgi.multiprocess'] = True | 42 environ[r'wsgi.multiprocess'] = True |
43 environ['wsgi.run_once'] = True | 43 environ[r'wsgi.run_once'] = True |
44 | 44 |
45 if environ.get('HTTPS', 'off').lower() in ('on', '1', 'yes'): | 45 if environ.get(r'HTTPS', r'off').lower() in (r'on', r'1', r'yes'): |
46 environ['wsgi.url_scheme'] = 'https' | 46 environ[r'wsgi.url_scheme'] = r'https' |
47 else: | 47 else: |
48 environ['wsgi.url_scheme'] = 'http' | 48 environ[r'wsgi.url_scheme'] = r'http' |
49 | 49 |
50 headers_set = [] | 50 headers_set = [] |
51 headers_sent = [] | 51 headers_sent = [] |
52 out = util.stdout | 52 out = util.stdout |
53 | 53 |