mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 13:35:16 +03:00
[common] new parameters for getHttps
This commit is contained in:
parent
0842913abf
commit
c768b29153
@ -344,7 +344,7 @@ def undeflate(data):
|
|||||||
|
|
||||||
# an http.client implementation of get_content()
|
# an http.client implementation of get_content()
|
||||||
# because urllib does not support "Connection: keep-alive"
|
# 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
|
import http.client
|
||||||
|
|
||||||
conn = http.client.HTTPSConnection(host)
|
conn = http.client.HTTPSConnection(host)
|
||||||
@ -353,8 +353,10 @@ def getHttps(host, url, headers, debuglevel=0):
|
|||||||
resp = conn.getresponse()
|
resp = conn.getresponse()
|
||||||
|
|
||||||
data = resp.read()
|
data = resp.read()
|
||||||
data = ungzip(data)
|
if gzip:
|
||||||
#data = undeflate(data)
|
data = ungzip(data)
|
||||||
|
if deflate:
|
||||||
|
data = undeflate(data)
|
||||||
|
|
||||||
return str(data, encoding='utf-8')
|
return str(data, encoding='utf-8')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user