mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
don't update, just insert new keys
This commit is contained in:
parent
4e3d09c64d
commit
d77b6d6faa
@ -20,7 +20,22 @@ log = logging.getLogger(__name__)
|
|||||||
def create(req, sock, client, server, cfg):
|
def create(req, sock, client, server, cfg):
|
||||||
resp = Response(req, sock)
|
resp = Response(req, sock)
|
||||||
|
|
||||||
environ = {}
|
environ = {
|
||||||
|
"wsgi.input": req.body,
|
||||||
|
"wsgi.errors": sys.stderr,
|
||||||
|
"wsgi.version": (1, 0),
|
||||||
|
"wsgi.multithread": False,
|
||||||
|
"wsgi.multiprocess": (cfg.workers > 1),
|
||||||
|
"wsgi.run_once": False,
|
||||||
|
"gunicorn.socket": sock,
|
||||||
|
"SERVER_SOFTWARE": SERVER_VERSION,
|
||||||
|
"REQUEST_METHOD": req.method,
|
||||||
|
"QUERY_STRING": req.query,
|
||||||
|
"RAW_URI": req.uri,
|
||||||
|
"SERVER_PROTOCOL": "HTTP/%s" % ".".join(map(str, req.version)),
|
||||||
|
"CONTENT_TYPE": "",
|
||||||
|
"CONTENT_LENGTH": ""
|
||||||
|
}
|
||||||
|
|
||||||
# authors should be aware that REMOTE_HOST and REMOTE_ADDR
|
# authors should be aware that REMOTE_HOST and REMOTE_ADDR
|
||||||
# may not qualify the remote addr:
|
# may not qualify the remote addr:
|
||||||
@ -48,16 +63,17 @@ def create(req, sock, client, server, cfg):
|
|||||||
elif hdr_name == "SCRIPT_NAME":
|
elif hdr_name == "SCRIPT_NAME":
|
||||||
script_name = hdr_value
|
script_name = hdr_value
|
||||||
elif hdr_name == "CONTENT-TYPE":
|
elif hdr_name == "CONTENT-TYPE":
|
||||||
content_type = hdr_value
|
environ['CONTENT_TYPE'] = hdr_value
|
||||||
|
continue
|
||||||
elif hdr_name == "CONTENT-LENGTH":
|
elif hdr_name == "CONTENT-LENGTH":
|
||||||
content_length = hdr_value
|
environ['CONTENT_LENGTH'] = hdr_value
|
||||||
|
continue
|
||||||
|
|
||||||
key = 'HTTP_' + hdr_name.replace('-', '_')
|
key = 'HTTP_' + hdr_name.replace('-', '_')
|
||||||
if key not in ('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'):
|
environ[key] = hdr_value
|
||||||
environ[key] = hdr_value
|
|
||||||
|
|
||||||
wsgi_multiprocess = (cfg.workers > 1)
|
|
||||||
|
|
||||||
|
environ['wsgi.url_scheme'] = url_scheme
|
||||||
|
|
||||||
|
|
||||||
if isinstance(forward, basestring):
|
if isinstance(forward, basestring):
|
||||||
# we only took the last one
|
# we only took the last one
|
||||||
@ -70,6 +86,9 @@ def create(req, sock, client, server, cfg):
|
|||||||
else:
|
else:
|
||||||
remote = forward
|
remote = forward
|
||||||
|
|
||||||
|
environ['REMOTE_ADDR'] = remote[0]
|
||||||
|
environ['REMOTE_PORT'] = str(remote[1])
|
||||||
|
|
||||||
if isinstance(server, basestring):
|
if isinstance(server, basestring):
|
||||||
server = server.split(":")
|
server = server.split(":")
|
||||||
if len(server) == 1:
|
if len(server) == 1:
|
||||||
@ -79,34 +98,14 @@ def create(req, sock, client, server, cfg):
|
|||||||
server.append("443")
|
server.append("443")
|
||||||
else:
|
else:
|
||||||
server.append('')
|
server.append('')
|
||||||
|
environ['SERVER_NAME'] = server[0]
|
||||||
|
environ['SERVER_PORT'] = server[1]
|
||||||
|
|
||||||
path_info = req.path
|
path_info = req.path
|
||||||
if script_name:
|
if script_name:
|
||||||
path_info = path_info.split(script_name, 1)[1]
|
path_info = path_info.split(script_name, 1)[1]
|
||||||
|
environ['PATH_INFO'] = unquote(path_info)
|
||||||
environ.update({
|
environ['SCRIPT_NAME'] = script_name
|
||||||
"wsgi.url_scheme": url_scheme,
|
|
||||||
"wsgi.input": req.body,
|
|
||||||
"wsgi.errors": sys.stderr,
|
|
||||||
"wsgi.version": (1, 0),
|
|
||||||
"wsgi.multithread": False,
|
|
||||||
"wsgi.multiprocess": wsgi_multiprocess,
|
|
||||||
"wsgi.run_once": False,
|
|
||||||
"gunicorn.socket": sock,
|
|
||||||
"SCRIPT_NAME": script_name,
|
|
||||||
"SERVER_SOFTWARE": SERVER_VERSION,
|
|
||||||
"REQUEST_METHOD": req.method,
|
|
||||||
"PATH_INFO": unquote(path_info),
|
|
||||||
"QUERY_STRING": req.query,
|
|
||||||
"RAW_URI": req.uri,
|
|
||||||
"CONTENT_TYPE": content_type,
|
|
||||||
"CONTENT_LENGTH": content_length,
|
|
||||||
"REMOTE_ADDR": remote[0],
|
|
||||||
"REMOTE_PORT": str(remote[1]),
|
|
||||||
"SERVER_NAME": server[0],
|
|
||||||
"SERVER_PORT": str(server[1]),
|
|
||||||
"SERVER_PROTOCOL": "HTTP/%s" % ".".join(map(str, req.version))
|
|
||||||
})
|
|
||||||
|
|
||||||
return resp, environ
|
return resp, environ
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user