mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
full wsgi environment.
This commit is contained in:
parent
84d739f1e4
commit
d63890c77a
@ -33,9 +33,10 @@ class HTTPRequest(object):
|
||||
SERVER_VERSION = "gunicorn/%s" % __version__
|
||||
CHUNK_SIZE = 4096
|
||||
|
||||
def __init__(self, socket, address):
|
||||
def __init__(self, socket, client_address, server_address):
|
||||
self.socket = socket
|
||||
self.address = address
|
||||
self.client_address = client_address
|
||||
self.server_address = server_address
|
||||
self.version = None
|
||||
self.method = None
|
||||
self.path = None
|
||||
@ -80,7 +81,12 @@ class HTTPRequest(object):
|
||||
"QUERY_STRING": query,
|
||||
"RAW_URI": self.path,
|
||||
"CONTENT_TYPE": self.headers.get('content-type', ''),
|
||||
"CONTENT_LENGTH": length
|
||||
"CONTENT_LENGTH": length,
|
||||
"REMOTE_ADDR": self.client_address[0],
|
||||
"REMOTE_PORT": self.client_address[1],
|
||||
"SERVER_NAME": self.server_address[0],
|
||||
"SERVER_PORT": self.server_address[1],
|
||||
"SERVER_PROTOCOL": self.version
|
||||
}
|
||||
|
||||
for key, value in self.headers.items():
|
||||
@ -88,6 +94,7 @@ class HTTPRequest(object):
|
||||
if key not in ('HTTP_CONTENT_TYPE', 'HTTP_CONTENT_LENGTH'):
|
||||
environ[key] = value
|
||||
|
||||
print environ
|
||||
return environ
|
||||
|
||||
def read_headers(self):
|
||||
|
||||
@ -102,10 +102,9 @@ class HTTPServer(object):
|
||||
pass
|
||||
|
||||
|
||||
def process_client(self, conn, addr):
|
||||
def process_client(self, listener, conn, addr):
|
||||
""" do nothing just echo message"""
|
||||
|
||||
req = HTTPRequest(conn, addr)
|
||||
req = HTTPRequest(conn, addr, listener.getsockname())
|
||||
environ = req.read()
|
||||
|
||||
req.write(str(environ))
|
||||
@ -128,7 +127,7 @@ class HTTPServer(object):
|
||||
try:
|
||||
for sock in ready:
|
||||
try:
|
||||
self.process_client(*sock.accept_nonblock())
|
||||
self.process_client(sock, *sock.accept_nonblock())
|
||||
except errno.EAGAIN, errno.ECONNABORTED:
|
||||
pass
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user