summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlinaro-cp.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/linaro-cp.py b/linaro-cp.py
index 9888d2b..c77998d 100755
--- a/linaro-cp.py
+++ b/linaro-cp.py
@@ -145,12 +145,15 @@ class API_v3(API_v1):
try:
with open(filename, 'rb') as f:
print("Uploading file %s" % filename)
+ s = requests.Session()
+ req = requests.Request('PUT', url, data=f, headers=headers)
+ prepped = req.prepare()
if size == 0:
- # Due to a request bug we need to use files system call
- # to get around https://github.com/requests/requests/issues/1648
- resp = requests.put(url, headers=headers, files=f, timeout=61)
- else:
- resp = requests.put(url, headers=headers, data=f, timeout=61)
+ # Due to a Python bug "Transfer-Encoding: chucked" gets
+ # added to 0 byte files.
+ # https://github.com/requests/requests/issues/1648
+ del prepped.headers['Transfer-Encoding']
+ resp = s.send(prepped, timeout=61)
if resp.status_code in (200, 201):
return
else: