From ea36277c99475f4961874dde08ab87ab4020ba13 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 23 May 2015 08:07:11 +0530 Subject: [PATCH] Send Keep-Alive header --- src/calibre/srv/http.py | 3 +++ src/calibre/srv/opts.py | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/calibre/srv/http.py b/src/calibre/srv/http.py index c5214c52a8..b7f5f5eaee 100644 --- a/src/calibre/srv/http.py +++ b/src/calibre/srv/http.py @@ -578,6 +578,9 @@ class HTTPPair(object): self.sent_headers = True self.outheaders.set('Date', http_date(), replace_all=True) self.outheaders.set('Server', 'calibre %s' % __version__, replace_all=True) + keep_alive = not self.close_connection and self.server_loop.opts.timeout > 0 + if keep_alive: + self.outheaders.set('Keep-Alive', 'timeout=%d' % self.server_loop.opts.timeout) if 'Connection' not in self.outheaders: if self.response_protocol is HTTP11: if self.close_connection: diff --git a/src/calibre/srv/opts.py b/src/calibre/srv/opts.py index c9463ab0d1..8734e04764 100644 --- a/src/calibre/srv/opts.py +++ b/src/calibre/srv/opts.py @@ -32,8 +32,8 @@ raw_options = ( 'request_queue_size', 5, None, - 'Timeout in seconds for accepted connections', - 'timeout', 10.0, + 'Time (in seconds) after which an idle connection is closed', + 'timeout', 60.0, None, 'Total time in seconds to wait for clean shutdown',