diff --git a/bin/service/http_server.py b/bin/service/http_server.py index f40e1df5ba8..e2ae90918b7 100644 --- a/bin/service/http_server.py +++ b/bin/service/http_server.py @@ -123,10 +123,12 @@ class HttpLogHandler: class MultiHandler2(HttpLogHandler, MultiHTTPHandler): _logger = logging.getLogger('http') + wbufsize = 32768 class SecureMultiHandler2(HttpLogHandler, SecureMultiHTTPHandler): _logger = logging.getLogger('https') + wbufsize = 32768 def getcert_fnames(self): tc = tools.config diff --git a/bin/service/websrv_lib.py b/bin/service/websrv_lib.py index 859845de8f8..dff77fa6a87 100644 --- a/bin/service/websrv_lib.py +++ b/bin/service/websrv_lib.py @@ -182,12 +182,13 @@ class FixSendError: self.send_header('Connection', 'close') self.send_header('Content-Length', len(content) or 0) self.end_headers() - if hasattr(self, '_flush'): - self._flush() if self.command != 'HEAD' and code >= 200 and code not in (204, 304): self.wfile.write(content) + if hasattr(self, '_flush'): + self._flush() + class HttpOptions: _HTTP_OPTIONS = {'Allow': ['OPTIONS' ] } @@ -395,6 +396,7 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler): return if not self.parse_rawline(): self.log_message("Could not parse rawline.") + self.wfile.flush() return # self.parse_request(): # Do NOT parse here. the first line should be the only @@ -403,6 +405,7 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler): if not self.parse_request(): return self.do_OPTIONS() + self.wfile.flush() return for vdir in self.server.vdirs: @@ -429,9 +432,11 @@ class MultiHTTPHandler(FixSendError, HttpOptions, BaseHTTPRequestHandler): "client closed connection", self.rlpath.rstrip()) else: raise + self.wfile.flush() return # if no match: self.send_error(404, "Path not found: %s" % self.path) + self.wfile.flush() return def _get_ignore_body(self,fore): diff --git a/bin/tiny_socket.py b/bin/tiny_socket.py index 6a0d9371ef5..44f7db04f01 100644 --- a/bin/tiny_socket.py +++ b/bin/tiny_socket.py @@ -61,15 +61,7 @@ class mysocket: def mysend(self, msg, exception=False, traceback=None): msg = cPickle.dumps([msg,traceback]) - size = len(msg) - self.sock.send('%8d' % size) - self.sock.send(exception and "1" or "0") - totalsent = 0 - while totalsent < size: - sent = self.sock.send(msg[totalsent:]) - if sent == 0: - raise RuntimeError, "socket connection broken" - totalsent = totalsent + sent + self.sock.sendall('%8d%s%s' % (len(msg), exception and "1" or "0", msg)) def myreceive(self): buf=''