From c95a0efe7973a660f4abcd13f4ea6211d72c4baa Mon Sep 17 00:00:00 2001 From: Clay Gerrard Date: Thu, 25 Jun 2015 01:44:10 -0700 Subject: [PATCH] Make ssync_sender a better HTTP client When a server responses with an error - if that error includes a body - the client should read the body. This cleans up some ugly eventlet/wsgi.server log output related to chunked transfer disconnect (invalid literal for int() with base 16). Change-Id: Ibd06ddee9f216fce07fa33c3a7d8306b59eb6d77 Closes-Bug: #1466138 --- swift/obj/ssync_sender.py | 1 + test/unit/obj/test_ssync_sender.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/swift/obj/ssync_sender.py b/swift/obj/ssync_sender.py index 0657b0fd59..3c099bfa2c 100644 --- a/swift/obj/ssync_sender.py +++ b/swift/obj/ssync_sender.py @@ -143,6 +143,7 @@ class Sender(object): self.daemon.node_timeout, 'connect receive'): self.response = self.connection.getresponse() if self.response.status != http.HTTP_OK: + self.response.read() raise exceptions.ReplicationException( 'Expected status %s; got %s' % (http.HTTP_OK, self.response.status)) diff --git a/test/unit/obj/test_ssync_sender.py b/test/unit/obj/test_ssync_sender.py index 11cd06f22e..c73bf6a609 100644 --- a/test/unit/obj/test_ssync_sender.py +++ b/test/unit/obj/test_ssync_sender.py @@ -80,6 +80,9 @@ class FakeResponse(object): self.fp = StringIO.StringIO( '%x\r\n%s\r\n0\r\n\r\n' % (len(chunk_body), chunk_body)) + def read(self, *args, **kwargs): + return '' + def close(self): self.close_called = True