Indicate full version in UserAgent HTTP header

This commit is contained in:
nemunaire 2015-01-01 21:46:57 +01:00
parent 1a04a107ac
commit 0d21b1fa2c
2 changed files with 7 additions and 3 deletions

View File

@ -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:

View File

@ -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