瀏覽代碼

Merge pull request #263 from shobull/master

[zookeeper] Set default HTTP header to accept "application/json" in REST api
Romain Rigaux 10 年之前
父節點
當前提交
03971ea
共有 1 個文件被更改,包括 4 次插入2 次删除
  1. 4 2
      apps/zookeeper/src/zookeeper/rest.py

+ 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'])