Skip to content

Commit

Permalink
add user defined headers to webservice
Browse files Browse the repository at this point in the history
  • Loading branch information
xlcnd committed Jul 7, 2014
1 parent c74342a commit 341b4d1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion isbnlib/dev/webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ class WEBService(object):

"""Class to query web services."""

def __init__(self, url, user_agent=UA, values=None):
def __init__(self, url, user_agent=UA, values=None, appheaders=None):
"""Initialize main properties."""
self._url = url
# headers to accept gzipped content
headers = {'Accept-Encoding': 'gzip', 'User-Agent': user_agent}
# add more user provided headers
if appheaders is not None: # pragma: no cover
headers.update(appheaders)
# if 'data' it does a PUT request (data must be urlencoded)
data = urlencode(values) if values else None
self._request = Request(url, data, headers=headers)
Expand Down

0 comments on commit 341b4d1

Please sign in to comment.