From c7da66a41b64e661b6b2f02f2a671477ac61c093 Mon Sep 17 00:00:00 2001 From: "tandrii@chromium.org" Date: Thu, 24 Mar 2016 09:52:24 +0000 Subject: [PATCH] Fix gerrit_util to use non None body. Gerrit requires Content-Length to be set for POST requests. httplib Python library has a bug which doesn't set Content-Length if the body is empty. Python BUGS: https://bugs.python.org/issue14721 (partial fix) https://bugs.python.org/issue23539 (full fix) The full fix only appears in 2.7.11 release changelog (technically, it's been fixed in 2.7.10 rc1, but 2.7.10 was not released): https://hg.python.org/cpython/raw-file/53d30ab403f1/Misc/NEWS R=andybons@chromium.org,szager@chromium.org BUG=579160 Review URL: https://codereview.chromium.org/1827653002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299459 0039d316-1c4b-4281-b951-d872f2087c98 --- gerrit_util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gerrit_util.py b/gerrit_util.py index 38ac6aa2f..acaacb289 100755 --- a/gerrit_util.py +++ b/gerrit_util.py @@ -479,7 +479,7 @@ def GetChangeReview(host, change, revision=None): def AbandonChange(host, change, msg=''): """Abandon a gerrit change.""" path = 'changes/%s/abandon' % change - body = {'message': msg} if msg else None + body = {'message': msg} if msg else {} conn = CreateHttpConn(host, path, reqtype='POST', body=body) return ReadHttpJsonResponse(conn, ignore_404=False) @@ -487,7 +487,7 @@ def AbandonChange(host, change, msg=''): def RestoreChange(host, change, msg=''): """Restore a previously abandoned change.""" path = 'changes/%s/restore' % change - body = {'message': msg} if msg else None + body = {'message': msg} if msg else {} conn = CreateHttpConn(host, path, reqtype='POST', body=body) return ReadHttpJsonResponse(conn, ignore_404=False)