[Pkg-libvirt-commits] [libvirt-sandbox] 27/42: docker: fix setting of Accept header

Guido Guenther agx at moszumanska.debian.org
Sat May 27 16:27:09 UTC 2017


This is an automated email from the git hooks/post-receive script.

agx pushed a commit to branch debian/experimental
in repository libvirt-sandbox.

commit aea26e0da5c3e156177f9f89b08d4dcf316d9a48
Author: Daniel P. Berrange <berrange at redhat.com>
Date:   Fri Jul 15 13:42:54 2016 +0100

    docker: fix setting of Accept header
    
    The code for adding the Accept header was doing so based
    on whether 'if json' but 'json' resolved to a module
    import name, not a local boolean. So the header was always
    added even for requests not expected to be json.
    
    Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
---
 libvirt-sandbox/image/sources/docker.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libvirt-sandbox/image/sources/docker.py b/libvirt-sandbox/image/sources/docker.py
index 01cf498..658d90a 100644
--- a/libvirt-sandbox/image/sources/docker.py
+++ b/libvirt-sandbox/image/sources/docker.py
@@ -266,8 +266,6 @@ class DockerSource(base.Source):
         debug("Fetching %s..." % url)
 
         req = urllib2.Request(url=url)
-        if json:
-            req.add_header("Accept", "application/json")
         for h in headers.keys():
             req.add_header(h, headers[h])
 
@@ -283,6 +281,11 @@ class DockerSource(base.Source):
 
     def _get_json(self, template, server, path, headers):
         try:
+            if headers is None:
+                headers = {}
+            else:
+                headers = copy.copy(headers)
+            headers["Accept"] = "application/json")
             res = self._get_url(template, server, path, headers)
             data = json.loads(res.read())
             debug("OK\n")

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libvirt-sandbox.git



More information about the Pkg-libvirt-commits mailing list