aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/storage
diff options
context:
space:
mode:
authorW. Trevor King <wking@tremily.us>2012-08-24 07:22:39 -0400
committerW. Trevor King <wking@tremily.us>2012-08-24 07:24:10 -0400
commiteb9f603707d932641b8c580bde91ddb7d54741e0 (patch)
treed97bf0df1ecde4aba076572b8734ac3003f7131a /libbe/storage
parent6b04e1f5b80abcc1dffbce0466f34a182a468064 (diff)
downloadbugseverywhere-eb9f603707d932641b8c580bde91ddb7d54741e0.tar.gz
storage:http: add agent argument to get_post_url.
This allows us to set an appropriate user agent if we use this function in other places (e.g. upcoming Command._run_remote).
Diffstat (limited to 'libbe/storage')
-rw-r--r--libbe/storage/http.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/libbe/storage/http.py b/libbe/storage/http.py
index 877fc96..cfed7b7 100644
--- a/libbe/storage/http.py
+++ b/libbe/storage/http.py
@@ -79,7 +79,7 @@ class InvalidURL (Exception):
return self.error.__str__()
return self.msg
-def get_post_url(url, get=True, data_dict=None, headers=[]):
+def get_post_url(url, get=True, data_dict=None, headers=[], agent=None):
"""Execute a GET or POST transaction.
Parameters
@@ -95,6 +95,8 @@ def get_post_url(url, get=True, data_dict=None, headers=[]):
"""
if data_dict == None:
data_dict = {}
+ if agent is None:
+ agent = USER_AGENT
if get == True:
if data_dict != {}:
# encode get parameters in the url
@@ -104,7 +106,7 @@ def get_post_url(url, get=True, data_dict=None, headers=[]):
else:
data = urllib.urlencode(data_dict)
headers = dict(headers)
- headers['User-Agent'] = USER_AGENT
+ headers['User-Agent'] = agent
req = urllib2.Request(url, data=data, headers=headers)
try:
response = urllib2.urlopen(req)