summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-08-10 23:08:21 +0200
committerJames Turnbull <james@lovedthanlost.net>2009-08-13 08:11:12 +1000
commit601a2e54aecccedfc0bdd94939d44cc07b4d6588 (patch)
tree31bbc59f277582b9d4ef04de519d2f2ff110b49d /lib/puppet/indirector
parentd86bc889390e56aa007b0099f9f407d4be98c876 (diff)
Fix #2516 - Fix format detection when content-type contains charset
Even though Puppet never transmist a charset information in its response/request content-type, some proxy (especially Apache with the infamous AddDefaultCharset configuration) may add this "incorrect" information. This patch makes sure that only the mime-type is used when looking for the format associated with a response or a request. The patch also provides a better error message when the client or server code is fed with a request whose mime-type can not be mapped to a known format. It also fixes a typo noticed by the original reporter. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/indirector')
-rw-r--r--lib/puppet/indirector/rest.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb
index 4d818c986..35847de88 100644
--- a/lib/puppet/indirector/rest.rb
+++ b/lib/puppet/indirector/rest.rb
@@ -41,11 +41,13 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
raise "No content type in http response; cannot parse"
end
+ content_type = response['content-type'].gsub(/\s*;.*$/,'') # strip any appended charset
+
# Convert the response to a deserialized object.
if multiple
- model.convert_from_multiple(response['content-type'], response.body)
+ model.convert_from_multiple(content_type, response.body)
else
- model.convert_from(response['content-type'], response.body)
+ model.convert_from(content_type, response.body)
end
else
# Raise the http error if we didn't get a 'success' of some kind.