diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/indirector/rest.rb | 2 | ||||
-rw-r--r-- | lib/puppet/network/http/mongrel/rest.rb | 19 | ||||
-rw-r--r-- | lib/puppet/network/http/webrick/rest.rb | 7 |
3 files changed, 13 insertions, 15 deletions
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb index 35847de88..e1ee89f04 100644 --- a/lib/puppet/indirector/rest.rb +++ b/lib/puppet/indirector/rest.rb @@ -51,7 +51,7 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus end else # Raise the http error if we didn't get a 'success' of some kind. - message = "Error %s on SERVER: %s" % [response.code, response.message] + message = "Error %s on SERVER: %s" % [response.code, (response.body||'').empty? ? response.message : response.body] raise Net::HTTPError.new(message, response) end end diff --git a/lib/puppet/network/http/mongrel/rest.rb b/lib/puppet/network/http/mongrel/rest.rb index 8a4de1cce..7b28d880b 100644 --- a/lib/puppet/network/http/mongrel/rest.rb +++ b/lib/puppet/network/http/mongrel/rest.rb @@ -50,16 +50,17 @@ class Puppet::Network::HTTP::MongrelREST < Mongrel::HttpHandler # produce the body of the response def set_response(response, result, status = 200) - args = [status] - # Set the 'reason' (or 'message', as it's called in Webrick), when - # we have a failure. - if status >= 300 - args << false << result - end - - response.start(*args) do |head, body| - body.write(result) + # we have a failure, unless we're on a version of mongrel that doesn't + # support this. + if status < 300 + response.start(status) { |head, body| body.write(result) } + else + begin + response.start(status,false,result) { |head, body| body.write(result) } + rescue ArgumentError + response.start(status) { |head, body| body.write(result) } + end end end diff --git a/lib/puppet/network/http/webrick/rest.rb b/lib/puppet/network/http/webrick/rest.rb index 287fa39ac..274665dcd 100644 --- a/lib/puppet/network/http/webrick/rest.rb +++ b/lib/puppet/network/http/webrick/rest.rb @@ -50,11 +50,8 @@ class Puppet::Network::HTTP::WEBrickREST < WEBrick::HTTPServlet::AbstractServlet def set_response(response, result, status = 200) response.status = status - if status >= 200 and status < 300 - response.body = result - else - response.reason_phrase = result - end + response.body = result if status >= 200 and status != 304 + response.reason_phrase = result if status < 200 or status >= 300 end # Retrieve node/cert/ip information from the request object. |