Comment 1 for bug 1135541

Revision history for this message
Stuart McLaren (stuart-mclaren) wrote : Re: v1 api returns location as header for cached images

Or to additionally handle the case where the response header's x-image-meta-location filed
has been populated:

$ git diff glance/api/v1/images.py
 diff --git a/glance/api/v1/images.py b/glance/api/v1/images.py
 index 7068820..3e8741c 100644
 --- a/glance/api/v1/images.py
 +++ b/glance/api/v1/images.py
 @@ -947,6 +947,10 @@ class ImageSerializer(wsgi.JSONResponseSerializer):
          self.notifier = notifier.Notifier()

      def _inject_location_header(self, response, image_meta):
 + if 'location' in image_meta:
 + del image_meta['location']
 + if 'x-image-meta-location' in response.headers:
 + del response.headers['x-image-meta-location']
          location = self._get_image_location(image_meta)
          response.headers['Location'] = location.encode('utf-8')