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
diff --git a/gerrit_util.py b/gerrit_util.py
index 38ac6aa..acaacb2 100755
--- a/gerrit_util.py
+++ b/gerrit_util.py
@@ -479,7 +479,7 @@
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 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)