request with User-Agent 'Isso/...', #151
This commit is contained in:
parent
56c81c2d06
commit
596acb7f79
@ -7,6 +7,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import http.client as httplib
|
import http.client as httplib
|
||||||
|
|
||||||
|
from isso import dist
|
||||||
from isso.wsgi import urlsplit
|
from isso.wsgi import urlsplit
|
||||||
|
|
||||||
|
|
||||||
@ -21,6 +22,10 @@ class curl(object):
|
|||||||
return resp.status
|
return resp.status
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"User-Agent": "Isso/{0} (+http://posativ.org/isso)".format(dist.version)
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, method, host, path, timeout=3):
|
def __init__(self, method, host, path, timeout=3):
|
||||||
self.method = method
|
self.method = method
|
||||||
self.host = host
|
self.host = host
|
||||||
@ -35,7 +40,7 @@ class curl(object):
|
|||||||
self.con = http(host, port, timeout=self.timeout)
|
self.con = http(host, port, timeout=self.timeout)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.con.request(self.method, self.path)
|
self.con.request(self.method, self.path, headers=self.headers)
|
||||||
except (httplib.HTTPException, socket.error):
|
except (httplib.HTTPException, socket.error):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user