mirror of
https://github.com/adulau/HHHash.git
synced 2024-12-22 08:46:05 +00:00
Merge remote-tracking branch 'upstream/master' into feature/from_banner
This commit is contained in:
commit
e4403fea99
2 changed files with 16 additions and 3 deletions
|
@ -2,10 +2,23 @@ import requests
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
|
||||||
def buildhash(url=None, debug=False):
|
def buildhash(url=None, debug=False, method='GET', timeout=5):
|
||||||
|
"""Build a HHHash from an HTTP request to specific url.
|
||||||
|
|
||||||
|
Keyword arguments:
|
||||||
|
url -- the url to build the HHHash from the response headers (default None)
|
||||||
|
debug -- output the headers returned before hashing (default False)
|
||||||
|
method -- HTTP method to use (GET or HEAD) (default GET)
|
||||||
|
timeout -- default timeout for the connect/read timeout of request (default 2)
|
||||||
|
"""
|
||||||
if url is None:
|
if url is None:
|
||||||
return False
|
return False
|
||||||
r = requests.get(url)
|
if method == 'GET':
|
||||||
|
r = requests.get(url, timeout=timeout)
|
||||||
|
elif method == 'HEAD':
|
||||||
|
r = requests.head(url, timeout=timeout)
|
||||||
|
else:
|
||||||
|
return False
|
||||||
hhhash = ""
|
hhhash = ""
|
||||||
for header in r.headers.keys():
|
for header in r.headers.keys():
|
||||||
hhhash = f"{hhhash}:{header}"
|
hhhash = f"{hhhash}:{header}"
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "HHHash"
|
name = "HHHash"
|
||||||
version = "0.1"
|
version = "0.2"
|
||||||
authors = [
|
authors = [
|
||||||
"Alexandre Dulaunoy <a@foo.be>"
|
"Alexandre Dulaunoy <a@foo.be>"
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue