From c768b291533129cdb0dcc8dcfbdfe3c6aa69d655 Mon Sep 17 00:00:00 2001 From: Mort Yao Date: Sun, 15 May 2022 22:50:09 +0200 Subject: [PATCH] [common] new parameters for getHttps --- src/you_get/common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/you_get/common.py b/src/you_get/common.py index 82534a85..c5c19d01 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -344,7 +344,7 @@ def undeflate(data): # an http.client implementation of get_content() # because urllib does not support "Connection: keep-alive" -def getHttps(host, url, headers, debuglevel=0): +def getHttps(host, url, headers, gzip=True, deflate=False, debuglevel=0): import http.client conn = http.client.HTTPSConnection(host) @@ -353,8 +353,10 @@ def getHttps(host, url, headers, debuglevel=0): resp = conn.getresponse() data = resp.read() - data = ungzip(data) - #data = undeflate(data) + if gzip: + data = ungzip(data) + if deflate: + data = undeflate(data) return str(data, encoding='utf-8')