1
0
Fork 0

tools/web: new function to retrieve only headers

This commit is contained in:
nemunaire 2018-08-30 07:59:41 +02:00
parent 4a636b2b11
commit 53fe00ed58
1 changed files with 15 additions and 0 deletions

View File

@ -138,6 +138,21 @@ def _URLConn(cb, url, body=None, timeout=7, header=None, follow_redir=True):
finally:
conn.close()
def getURLHeaders(url, body=None, timeout=7, header=None, follow_redir=True):
"""Return page headers corresponding to URL or None if any error occurs
Arguments:
url -- the URL to get
body -- Data to send as POST content
timeout -- maximum number of seconds to wait before returning an exception
"""
def next(res):
return res.status, res.getheaders()
return _URLConn(next, url=url, body=body, timeout=timeout, header=header, follow_redir=follow_redir)
def getURLContent(url, body=None, timeout=7, header=None, decode_error=False,
max_size=524288):
"""Return page content corresponding to URL or None if any error occurs