Indicate full version in UserAgent HTTP header
This commit is contained in:
parent
1a04a107ac
commit
0d21b1fa2c
|
@ -4,6 +4,7 @@ import subprocess
|
|||
import tempfile
|
||||
import urllib
|
||||
|
||||
from bot import __version__
|
||||
from tools import web
|
||||
|
||||
|
||||
|
@ -27,7 +28,8 @@ def headers(url):
|
|||
else:
|
||||
conn = http.client.HTTPSConnection(o.hostname, port=o.port, timeout=5)
|
||||
try:
|
||||
conn.request("HEAD", o.path, None, {"User-agent": "Nemubot v3"})
|
||||
conn.request("HEAD", o.path, None, {"User-agent":
|
||||
"Nemubot v%s" % __version__})
|
||||
except socket.timeout:
|
||||
raise IRCException("request timeout")
|
||||
except socket.gaierror:
|
||||
|
|
|
@ -25,6 +25,7 @@ from urllib.parse import quote
|
|||
from urllib.parse import urlparse
|
||||
from urllib.request import urlopen
|
||||
|
||||
from bot import __version__
|
||||
from exception import IRCException
|
||||
from tools.xmlparser import parse_string
|
||||
|
||||
|
@ -87,9 +88,10 @@ def getURLContent(url, timeout=15):
|
|||
try:
|
||||
if o.query != '':
|
||||
conn.request("GET", o.path + "?" + o.query,
|
||||
None, {"User-agent": "Nemubot v3"})
|
||||
None, {"User-agent": "Nemubot v%s" % __version__})
|
||||
else:
|
||||
conn.request("GET", o.path, None, {"User-agent": "Nemubot v3"})
|
||||
conn.request("GET", o.path, None, {"User-agent":
|
||||
"Nemubot v%s" % __version__})
|
||||
except socket.timeout:
|
||||
return None
|
||||
except OSError: # [Errno 113] No route to host
|
||||
|
|
Loading…
Reference in New Issue
Block a user