summaryrefslogtreecommitdiffstats
path: root/lib/puppet/network/http/mongrel
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-07-05 19:38:01 +0200
committerBrice Figureau <brice-puppet@daysofwonder.com>2009-07-05 22:46:05 +0200
commit1e83aadc749aea9d52281d4f4041f6144a7229c7 (patch)
treecedb6c50b6b5c365d010e48fc42a74b1a5dc823a /lib/puppet/network/http/mongrel
parentaaca17a26092f3fece9a835eddf3ad6b9cf82300 (diff)
downloadpuppet-1e83aadc749aea9d52281d4f4041f6144a7229c7.tar.gz
puppet-1e83aadc749aea9d52281d4f4041f6144a7229c7.tar.xz
puppet-1e83aadc749aea9d52281d4f4041f6144a7229c7.zip
Fix #2392 - use Content-Type for REST communication
There were two problems: * server->client communications is using Content-Type with the direct format name instead of the format mime-type. * client->server communications is not using Content-Type to send the format of the serialized object. Instead it is using the first member of the Accept header. The Accept header is usually reserved for the other side, ie what the client will accept when the server will respond. This patch makes sure s->c communication contains correct Content-Type headers. This patch also adds a Content-Type header containing the mime-type of the object sent by the client when saving. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/network/http/mongrel')
-rw-r--r--lib/puppet/network/http/mongrel/rest.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/puppet/network/http/mongrel/rest.rb b/lib/puppet/network/http/mongrel/rest.rb
index 369d4c6c4..fe1ed1088 100644
--- a/lib/puppet/network/http/mongrel/rest.rb
+++ b/lib/puppet/network/http/mongrel/rest.rb
@@ -15,6 +15,10 @@ class Puppet::Network::HTTP::MongrelREST < Mongrel::HttpHandler
request.params[ACCEPT_HEADER]
end
+ def content_type_header(request)
+ request.params["HTTP_CONTENT_TYPE"]
+ end
+
# which HTTP verb was used in this request
def http_method(request)
request.params[Mongrel::Const::REQUEST_METHOD]
@@ -41,7 +45,7 @@ class Puppet::Network::HTTP::MongrelREST < Mongrel::HttpHandler
end
def set_content_type(response, format)
- response.header['Content-Type'] = format
+ response.header['Content-Type'] = format_to_mime(format)
end
# produce the body of the response