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