Эх сурвалжийг харах

Merge pull request #263 from shobull/master

[zookeeper] Set default HTTP header to accept "application/json" in REST api
Romain Rigaux 10 жил өмнө
parent
commit
03971ea396

+ 4 - 2
apps/zookeeper/src/zookeeper/rest.py

@@ -171,8 +171,10 @@ class ZooKeeper(object):
     def _do_get(self, uri):
         """ Send a GET request and convert errors to exceptions """
         try:
-            req = urllib2.urlopen(uri)
-            resp = json.load(req)
+            req = urllib2.Request(uri)
+            req.add_header("Accept", "application/json");
+            r = urllib2.urlopen(req)
+            resp = json.load(r)
 
             if 'Error' in resp:
                raise ZooKeeper.Error(resp['Error'])