vendored/puppet/lib/puppet/indirector/rest.rb in bolt-0.11.0 vs vendored/puppet/lib/puppet/indirector/rest.rb in bolt-0.12.0

- old
+ new

@@ -181,11 +181,11 @@ # reason to why something is not found - it may not be the thing the user is # expecting to find that is missing, but something else (like the environment). # While this way of handling the issue is not perfect, there is at least an error # that makes a user aware of the reason for the failure. # - content_type, body = parse_response(response) + _, body = parse_response(response) msg = _("Find %{uri} resulted in 404 with the message: %{body}") % { uri: elide(uri_with_query_string, 100), body: body } raise Puppet::Error, msg else nil end @@ -260,15 +260,17 @@ response end def handle_response(request, response) server_version = response[Puppet::Network::HTTP::HEADER_PUPPET_VERSION] - if server_version && - SemanticPuppet::Version.parse(server_version).major < MAJOR_VERSION_JSON_DEFAULT && - Puppet[:preferred_serialization_format] != 'pson' - Puppet.warning("Downgrading to PSON for future requests") - Puppet[:preferred_serialization_format] = 'pson' + if server_version + Puppet.push_context({:server_agent_version => server_version}) + if SemanticPuppet::Version.parse(server_version).major < MAJOR_VERSION_JSON_DEFAULT && + Puppet[:preferred_serialization_format] != 'pson' + Puppet.warning("Downgrading to PSON for future requests") + Puppet[:preferred_serialization_format] = 'pson' + end end end def validate_key(request) # Validation happens on the remote end @@ -313,11 +315,10 @@ # Returns the content_type, stripping any appended charset, and the # body, decompressed if necessary (content-encoding is checked inside # uncompress_body) def parse_response(response) if response['content-type'] - [ response['content-type'].gsub(/\s*;.*$/,''), - body = uncompress_body(response) ] + [ response['content-type'].gsub(/\s*;.*$/,''), uncompress_body(response) ] else raise _("No content type in http response; cannot parse") end end