Permalink
Browse files

Added additional_headers to GoogleMap to anable specifying request he…

…aders such as Accept-Language
  • Loading branch information...
kanterov committed Nov 7, 2010
1 parent d04037f commit 0167d82788b73ca1c4887febffee1731ee5d431f
Showing with 4 additions and 1 deletion.
  1. +4 −1 googlemaps/googlemaps.py
View
@@ -28,6 +28,7 @@
VERSION = '1.0.3'
__all__ = ['GoogleMaps', 'GoogleMapsError']
+additional_headers={}
def fetch_json(query_url, params={}, headers={}): # pylint: disable-msg=W0102
"""Retrieve a JSON object from a (parameterized) URL.
@@ -46,10 +47,12 @@ def fetch_json(query_url, params={}, headers={}): # pylint: disable-msg=W0
"""
encoded_params = urllib.urlencode(params)
url = query_url + encoded_params
+
+ headers.update(additional_headers)
+
request = urllib2.Request(url, headers=headers)
response = urllib2.urlopen(request)
return (url, json.load(response))
-
class GoogleMapsError(Exception):
"""Base class for errors in the :mod:`googlemaps` module.

0 comments on commit 0167d82

Please sign in to comment.