diff options
| author | Markus Roberts <Markus@reality.com> | 2009-09-08 17:28:21 -0700 |
|---|---|---|
| committer | James Turnbull <james@lovedthanlost.net> | 2009-09-15 06:47:14 +1000 |
| commit | a45c4354b9ed8deaeb3173a495f06602472faebe (patch) | |
| tree | dcf0d250cb432d0dd8eb1416d03ad8ede764b8be /lib/puppet/network/http/mongrel | |
| parent | 7404e31d1ec418e9fdc276e0e619c045567cc00c (diff) | |
| download | puppet-a45c4354b9ed8deaeb3173a495f06602472faebe.tar.gz puppet-a45c4354b9ed8deaeb3173a495f06602472faebe.tar.xz puppet-a45c4354b9ed8deaeb3173a495f06602472faebe.zip | |
Fix for #2600 (wrong number of arguments under older mongrel)
This was an API compatibility problem with mongrel's HTTPResponse.start()
method between Mongrel 1.0.x and 1.1.x (the number of parameters changed).
The older version does not provide the option to set the response header
message which was used (redundantly with the response body) to return the
error message when the HTTP response was signaling an error.
In order to suport the older version the call was wrapped with a fallback
and the coresponding code in the other rest implementations was adjusted
to always send the error message in the response body. Then the rest
terminus was adjusted to pull the message from the response body (if it
is present) rather than from the header (which is only used as a fallback
for dealing with older puppetmasters), and the tests were augmeted to
verify this behaviour.
Signed-off-by: Markus Roberts <Markus@reality.com>
Diffstat (limited to 'lib/puppet/network/http/mongrel')
| -rw-r--r-- | lib/puppet/network/http/mongrel/rest.rb | 19 |
1 files changed, 10 insertions, 9 deletions
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 |
