Browse Source

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 10 years ago
parent
commit
80c9d9fe0a
  1. 4
      servefile

4
servefile

@ -74,6 +74,7 @@ class FileBaseHandler(BaseHTTPServer.BaseHTTPRequestHandler): @@ -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): @@ -339,6 +340,7 @@ class DirListingHandler(FileBaseHandler):
</body>
</html>""" % 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): @@ -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): @@ -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)

Loading…
Cancel
Save