summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-08-24 21:17:15 -0500
committerLuke Kanies <luke@madstop.com>2008-08-26 22:40:41 -0700
commit151a54ff7ac69aa2fa1708188ad75e444158e8a2 (patch)
tree5cfe9c206a819a2131fa146e1e04b9423b0f20b4 /lib
parentdeda6465f50b582f3b8c77204965db331ba81faa (diff)
downloadpuppet-151a54ff7ac69aa2fa1708188ad75e444158e8a2.tar.gz
puppet-151a54ff7ac69aa2fa1708188ad75e444158e8a2.tar.xz
puppet-151a54ff7ac69aa2fa1708188ad75e444158e8a2.zip
Causing format selection to fail intelligently if no suitable format can be picked.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/network/http/handler.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/puppet/network/http/handler.rb b/lib/puppet/network/http/handler.rb
index 6f5117b16..7c7abccf5 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -12,7 +12,18 @@ module Puppet::Network::HTTP::Handler
# Which format to use when serializing our response. Just picks
# the first value in the accept header, at this point.
def format_to_use(request)
- accept_header(request).split(/,\s*/)[0]
+ unless header = accept_header(request)
+ raise ArgumentError, "An Accept header must be provided to pick the right format"
+ end
+
+ format = nil
+ header.split(/,\s*/).each do |name|
+ next unless format = Puppet::Network::FormatHandler.format(name)
+ next unless format.suitable?
+ return name
+ end
+
+ raise "No specified acceptable formats (%s) are functional on this machine" % header
end
def initialize_for_puppet(args = {})