diff options
author | liuxu <i@liuxu.me> | 2018-12-01 18:58:38 +0300 |
---|---|---|
committer | Matt Martz <matt@sivel.net> | 2018-12-03 19:26:09 +0300 |
commit | a8a32650015997f7847f2de72a29ff7906f53d8a (patch) | |
tree | 36dfae35ddf9f63dc5e936fd8bfda83de23f3265 | |
parent | b2654de4107b236eb5417c1ebeeebbf82a391d71 (diff) |
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
-rwxr-xr-x | speedtest.py | 4 |
1 files changed, 3 insertions, 1 deletions
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 ) ) |