diff --git a/swift/common/bufferedhttp.py b/swift/common/bufferedhttp.py index e07cab24bb..d4a977c21e 100644 --- a/swift/common/bufferedhttp.py +++ b/swift/common/bufferedhttp.py @@ -30,6 +30,7 @@ from swift import gettext_ as _ from urllib import quote import logging import time +import socket from eventlet.green.httplib import CONTINUE, HTTPConnection, HTTPMessage, \ HTTPResponse, HTTPSConnection, _UNKNOWN @@ -105,7 +106,9 @@ class BufferedHTTPConnection(HTTPConnection): def connect(self): self._connected_time = time.time() - return HTTPConnection.connect(self) + ret = HTTPConnection.connect(self) + self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1) + return ret def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0): self._method = method diff --git a/test/unit/common/test_bufferedhttp.py b/test/unit/common/test_bufferedhttp.py index e3e1f96e17..a663a3d121 100644 --- a/test/unit/common/test_bufferedhttp.py +++ b/test/unit/common/test_bufferedhttp.py @@ -15,6 +15,8 @@ import unittest +import socket + from eventlet import spawn, Timeout, listen from swift.common import bufferedhttp @@ -60,6 +62,8 @@ class TestBufferedHTTP(unittest.TestCase): 'x-header': 'value'}, query_string='omg&no=%7f') conn.send('REQUEST\r\n') + self.assertTrue(conn.sock.getsockopt(socket.IPPROTO_TCP, + socket.TCP_NODELAY)) resp = conn.getresponse() body = resp.read() conn.close()