From a8a32650015997f7847f2de72a29ff7906f53d8a Mon Sep 17 00:00:00 2001 From: liuxu Date: Sat, 1 Dec 2018 23:58:38 +0800 Subject: [PATCH] Fix python3 upload problem In python3, if Content-length is not set,urllib.request.AbstractHTTPHandler::do_request_() will use "Transfer-encoding:chunked", which will cause HTTPUploader not to exit until timeout --- speedtest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/speedtest.py b/speedtest.py index 276cf3f..14d2dd6 100755 --- a/speedtest.py +++ b/speedtest.py @@ -1522,9 +1522,11 @@ class Speedtest(object): ) if pre_allocate: data.pre_allocate() + + headers = {'Content-length': size} requests.append( ( - build_request(self.best['url'], data, secure=self._secure), + build_request(self.best['url'], data, secure=self._secure, headers=headers), size ) )