Connection: close headers to disable http-keep-alive

Some Connection: close headers are needed so clients know that
servefile does not support keepalive connections.
tests
Sebastian Lohff 12 years ago
parent 72b561ace7
commit 80c9d9fe0a

@ -74,6 +74,7 @@ class FileBaseHandler(BaseHTTPServer.BaseHTTPRequestHandler):
if fileLength >= 0: if fileLength >= 0:
self.send_header('Content-Length', str(fileLength)) self.send_header('Content-Length', str(fileLength))
self.send_header('Connection', 'close')
self.send_header('Last-Modified', lastModified) self.send_header('Last-Modified', lastModified)
self.send_header('Content-Type', 'application/octet-stream') self.send_header('Content-Type', 'application/octet-stream')
self.send_header('Content-Disposition', 'attachment; filename="%s"' % fileName) self.send_header('Content-Disposition', 'attachment; filename="%s"' % fileName)
@ -339,6 +340,7 @@ class DirListingHandler(FileBaseHandler):
</body> </body>
</html>""" % self.escapeHTML(urllib.unquote(self.path)) </html>""" % self.escapeHTML(urllib.unquote(self.path))
self.send_header("Content-Length", str(len(errorMsg))) self.send_header("Content-Length", str(len(errorMsg)))
self.send_header('Connection', 'close')
self.end_headers() self.end_headers()
if not head: if not head:
self.wfile.write(errorMsg) self.wfile.write(errorMsg)
@ -452,6 +454,7 @@ class DirListingHandler(FileBaseHandler):
self.end_headers() self.end_headers()
return return
self.send_header("Content-Length", str(len(listing))) self.send_header("Content-Length", str(len(listing)))
self.send_header('Connection', 'close')
self.end_headers() self.end_headers()
self.wfile.write(listing) self.wfile.write(listing)
@ -596,6 +599,7 @@ class FilePutter(BaseHTTPServer.BaseHTTPRequestHandler):
self.send_response(code) self.send_response(code)
self.send_header('Content-Type', 'text/html') self.send_header('Content-Type', 'text/html')
self.send_header('Content-Length', str(len(msg))) self.send_header('Content-Length', str(len(msg)))
self.send_header('Connection', 'close')
self.end_headers() self.end_headers()
self.wfile.write(msg) self.wfile.write(msg)

Loading…
Cancel
Save