Created
January 23, 2010 02:19
-
-
Save viraptor/284381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
if asbool(static_files): | |
# Serve static files | |
static_app = StaticURLParser(config['pylons.paths']['static_files']) | |
app = Cascade([static_app, app]) | |
app = CloseConnection(app) | |
return app | |
class CloseConnection: | |
def __init__(self, app): | |
self.app = app | |
def __call__(self, environ, start_response): | |
def close_connection_start_response(status, headers, exc_info=None): | |
final_headers = [] | |
for header in headers: | |
if header[0].lower() != 'connection': | |
final_headers.append(header) | |
final_headers.append(('connection','close')) | |
return start_response(status, final_headers, exc_info) | |
return self.app(environ, close_connection_start_response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment