From 80c9d9fe0a3b7c8b1374c8978ada79b94c08d8e2 Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Tue, 13 Nov 2012 03:01:05 +0100 Subject: [PATCH] Connection: close headers to disable http-keep-alive Some Connection: close headers are needed so clients know that servefile does not support keepalive connections. --- servefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/servefile b/servefile index 3edc3a4..b2332eb 100755 --- a/servefile +++ b/servefile @@ -74,6 +74,7 @@ class FileBaseHandler(BaseHTTPServer.BaseHTTPRequestHandler): if fileLength >= 0: self.send_header('Content-Length', str(fileLength)) + self.send_header('Connection', 'close') self.send_header('Last-Modified', lastModified) self.send_header('Content-Type', 'application/octet-stream') self.send_header('Content-Disposition', 'attachment; filename="%s"' % fileName) @@ -339,6 +340,7 @@ class DirListingHandler(FileBaseHandler): """ % self.escapeHTML(urllib.unquote(self.path)) self.send_header("Content-Length", str(len(errorMsg))) + self.send_header('Connection', 'close') self.end_headers() if not head: self.wfile.write(errorMsg) @@ -452,6 +454,7 @@ class DirListingHandler(FileBaseHandler): self.end_headers() return self.send_header("Content-Length", str(len(listing))) + self.send_header('Connection', 'close') self.end_headers() self.wfile.write(listing) @@ -596,6 +599,7 @@ class FilePutter(BaseHTTPServer.BaseHTTPRequestHandler): self.send_response(code) self.send_header('Content-Type', 'text/html') self.send_header('Content-Length', str(len(msg))) + self.send_header('Connection', 'close') self.end_headers() self.wfile.write(msg)