0
@@ -33,18 +33,58 @@ def should_keep_alive(env):
0
+ def __init__(self, client):
0
+ def __call__(self, status_string, response_headers, exc_info=None):
0
+ # status_string should be something like "200 OK" or "404 Not Found"
0
+ # need to split this into an integer and human readable string for ebb
0
+ match = re.search('(\d+) (.*)', status_string)
0
+ status = int(match.group(1))
0
+ reason_phrase = match.group(2)
0
+ self.client.write_status(status, reason_phrase)
0
+ headers = Headers(response_headers)
0
+ # Decide if we should keep the connection alive or not
0
+ if not headers.has_key('Connection'):
0
+ if headers.has_key('Content-Length') and should_keep_alive(self.client.env()):
0
+ headers['Connection'] = 'Keep-Alive'
0
+ headers['Connection'] = 'close'
0
+ for field, value in headers.items():
0
+ self.client.write_header(field, value)
0
+ # This should return a write() object. but it's stupid and I don't want
0
+def request_wsgi1(app, client):
0
+ body = app.__call__(client.env(), StartResponse(client))
0
+ client.write_body(part)
0
-def request_cb(app, client):
0
+def request_wsgi2(app, client):
0
status_string, header_list, body = app.__call__(client.env())
0
# status_string should be something like "200 OK" or "404 Not Found"
0
# need to split this into an integer and human readable string for ebb
0
match = re.search('(\d+) (.*)', status_string)
0
status = int(match.group(1))
0
- status_human = match.group(2)
0
+ reason_phrase = match.group(2)
0
- client.write_status(status, status_human)
0
+ client.write_status(status, reason_phrase)
0
headers = Headers(header_list)
0
if not headers.has_key('Content-Length'):
0
@@ -60,7 +100,8 @@ def request_cb(app, client):
0
for field, value in headers.items():
0
client.write_header(field, value)
0
client.write_body(part)
0
@@ -84,4 +125,9 @@ def start_server(app, args = {}):
0
ebb_ffi.listen_on_port(port)
0
print "Ebb is listening at http://0.0.0.0:%d/" % port
0
- ebb_ffi.process_connections(app, request_cb)
0
\ No newline at end of file
0
+ if args.has_key('wsgi_version') and args['wsgi_version'] >= (2,0):
0
+ ebb_ffi.process_connections(app, cb)
0
\ No newline at end of file
Comments
No one has commented yet.