mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
fix SERVER_PROTOCOL in WSGI environ and fix gevent one.
This commit is contained in:
parent
9a46f105f2
commit
ae721f00d0
@ -98,7 +98,7 @@ def create(req, sock, client, server, cfg):
|
|||||||
"REMOTE_PORT": str(remote[1]),
|
"REMOTE_PORT": str(remote[1]),
|
||||||
"SERVER_NAME": server[0],
|
"SERVER_NAME": server[0],
|
||||||
"SERVER_PORT": str(server[1]),
|
"SERVER_PORT": str(server[1]),
|
||||||
"SERVER_PROTOCOL": req.version
|
"SERVER_PROTOCOL": "HTTP/%s" % ".".join(map(str, req.version))
|
||||||
}
|
}
|
||||||
|
|
||||||
for key, value in req.headers:
|
for key, value in req.headers:
|
||||||
|
|||||||
@ -103,17 +103,15 @@ class GeventBaseWorker(Worker):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def setup(cls):
|
def setup(cls):
|
||||||
from gevent import monkey
|
from gevent import monkey
|
||||||
monkey.patch_all(dns=False)
|
monkey.patch_all()
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.socket.setblocking(1)
|
self.socket.setblocking(1)
|
||||||
pool = Pool(self.worker_connections)
|
pool = Pool(self.worker_connections)
|
||||||
|
self.server_class.base_env['wsgi.multiprocess'] = (self.cfg.workers > 1)
|
||||||
server = self.server_class(self.socket, application=self.wsgi,
|
server = self.server_class(self.socket, application=self.wsgi,
|
||||||
spawn=pool, handler_class=self.wsgi_handler)
|
spawn=pool, handler_class=self.wsgi_handler)
|
||||||
|
|
||||||
server.start()
|
server.start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
while self.alive:
|
while self.alive:
|
||||||
self.notify()
|
self.notify()
|
||||||
@ -131,6 +129,12 @@ class GeventBaseWorker(Worker):
|
|||||||
class WSGIHandler(wsgi.WSGIHandler):
|
class WSGIHandler(wsgi.WSGIHandler):
|
||||||
def log_request(self, *args):
|
def log_request(self, *args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def prepare_env(self):
|
||||||
|
env = super(WSGIHandler, self).prepare_env()
|
||||||
|
env['RAW_URI'] = self.request.uri
|
||||||
|
return env
|
||||||
|
|
||||||
|
|
||||||
class WSGIServer(wsgi.WSGIServer):
|
class WSGIServer(wsgi.WSGIServer):
|
||||||
base_env = BASE_WSGI_ENV
|
base_env = BASE_WSGI_ENV
|
||||||
@ -144,6 +148,12 @@ class GeventWSGIWorker(GeventBaseWorker):
|
|||||||
class PyWSGIHandler(pywsgi.WSGIHandler):
|
class PyWSGIHandler(pywsgi.WSGIHandler):
|
||||||
def log_request(self, *args):
|
def log_request(self, *args):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_environ(self):
|
||||||
|
env = super(PyWSGIHandler, self).get_environ()
|
||||||
|
env['gunicorn.sock'] = self.socket
|
||||||
|
env['RAW_URI'] = self.path
|
||||||
|
return env
|
||||||
|
|
||||||
class PyWSGIServer(pywsgi.WSGIServer):
|
class PyWSGIServer(pywsgi.WSGIServer):
|
||||||
base_env = BASE_WSGI_ENV
|
base_env = BASE_WSGI_ENV
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user