Skip to content

Commit 0eca108

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Decode the metadata response before sending it to the VM" into stable/2025.1
2 parents 3421cb6 + d84c51f commit 0eca108

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

neutron/common/metadata.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
PROXY_SERVICE_NAME = 'haproxy'
3434
PROXY_SERVICE_CMD = 'haproxy'
3535

36+
CONTENT_ENCODERS = ('gzip', 'deflate')
37+
3638

3739
class InvalidUserOrGroupException(Exception):
3840
pass
@@ -162,6 +164,12 @@ def _http_response(http_response, request):
162164
status=http_response.status_code,
163165
content_type=http_response.headers['content-type'],
164166
charset=http_response.encoding)
167+
# The content of the response is decoded depending on the
168+
# "Context-Enconding" header, if present. The operation is limited to
169+
# ("gzip", "deflate"), as is in the ``webob.response.Response`` class.
170+
if _res.content_encoding in CONTENT_ENCODERS:
171+
_res.decode_content()
172+
165173
# NOTE(ralonsoh): there should be a better way to format the HTTP
166174
# response, adding the HTTP version to the ``webob.Response``
167175
# output string.

0 commit comments

Comments
 (0)