Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added additional_headers to GoogleMap to anable specifying request he…

…aders such as Accept-Language
  • Loading branch information...
commit 0167d82788b73ca1c4887febffee1731ee5d431f 1 parent d04037f
@kanterov authored
Showing with 4 additions and 1 deletion.
  1. +4 −1 googlemaps/googlemaps.py
View
5 googlemaps/googlemaps.py
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.