lib/puppet/network/http/handler.rb in puppet-3.3.0 vs lib/puppet/network/http/handler.rb in puppet-3.3.1.rc1

- old
+ new

@@ -82,10 +82,12 @@ request_headers = headers(request) request_params = params(request) request_method = http_method(request) request_path = path(request) + response[Puppet::Network::HTTP::HEADER_PUPPET_VERSION] = Puppet.version + configure_profiler(request_headers, request_params) Puppet::Util::Profiler.profile("Processed request #{request_method} #{request_path}") do indirection, method, key, params = uri2indirection(request_method, request_path, request_params) @@ -95,11 +97,11 @@ send("do_#{method}", indirection, key, params, request, response) end rescue SystemExit,NoMemoryError raise rescue HTTPError => e - return do_exception(response, e.message, e.status) + return do_http_control_exception(response, e) rescue Exception => e return do_exception(response, e) ensure cleanup(request) end @@ -119,15 +121,11 @@ # make sure we return the correct status code # for authorization issues status = 403 if status == 400 end - if exception.is_a?(Exception) - Puppet.log_exception(exception) - else - Puppet.notice(exception.to_s) - end + Puppet.log_exception(exception) set_content_type(response, "text/plain") set_response(response, exception.to_s, status) end @@ -216,9 +214,16 @@ end result[:ip] end private + + def do_http_control_exception(response, exception) + msg = exception.message + Puppet.info(msg) + set_content_type(response, "text/plain") + set_response(response, msg, exception.status) + end def report_if_deprecated(format) if format.name == :yaml || format.name == :b64_zlib_yaml Puppet.deprecation_warning("YAML in network requests is deprecated and will be removed in a future version. See http://links.puppetlabs.com/deprecate_yaml_on_network") end