summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-04-12 17:11:02 -0700
committerNick Lewis <nick@puppetlabs.com>2011-04-12 17:11:02 -0700
commitd748338e69b705585f9ac6bf2fd8da1e9163839b (patch)
tree8cd3d4a945fd5df18317db51fabd3f27767d9db4 /lib
parent40adee4ade3a447a7397a71d76e042091bbbfbff (diff)
parent46721411066926aff3a7d5bb6470d3b8aec1b47d (diff)
downloadpuppet-d748338e69b705585f9ac6bf2fd8da1e9163839b.tar.gz
puppet-d748338e69b705585f9ac6bf2fd8da1e9163839b.tar.xz
puppet-d748338e69b705585f9ac6bf2fd8da1e9163839b.zip
Merge branch 'ticket/next/6117' into next
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/indirector/rest.rb12
-rw-r--r--lib/puppet/network/http/api/v1.rb8
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/puppet/indirector/rest.rb b/lib/puppet/indirector/rest.rb
index e50dc68ae..0d3997221 100644
--- a/lib/puppet/indirector/rest.rb
+++ b/lib/puppet/indirector/rest.rb
@@ -72,7 +72,17 @@ class Puppet::Indirector::REST < Puppet::Indirector::Terminus
end
def find(request)
- return nil unless result = deserialize(network(request).get(indirection2uri(request), headers))
+ uri, body = request_to_uri_and_body(request)
+ uri_with_query_string = "#{uri}?#{body}"
+ http_connection = network(request)
+ # WEBrick in Ruby 1.9.1 only supports up to 1024 character lines in an HTTP request
+ # http://redmine.ruby-lang.org/issues/show/3991
+ response = if "GET #{uri_with_query_string} HTTP/1.1\r\n".length > 1024
+ http_connection.post(uri, body, headers)
+ else
+ http_connection.get(uri_with_query_string, headers)
+ end
+ result = deserialize response
result.name = request.key if result.respond_to?(:name=)
result
end
diff --git a/lib/puppet/network/http/api/v1.rb b/lib/puppet/network/http/api/v1.rb
index 5fe143979..61307f01e 100644
--- a/lib/puppet/network/http/api/v1.rb
+++ b/lib/puppet/network/http/api/v1.rb
@@ -8,6 +8,9 @@ module Puppet::Network::HTTP::API::V1
:plural => :search,
:singular => :find
},
+ "POST" => {
+ :singular => :find,
+ },
"PUT" => {
:singular => :save
},
@@ -41,6 +44,11 @@ module Puppet::Network::HTTP::API::V1
"/#{request.environment.to_s}/#{indirection}/#{request.escaped_key}#{request.query_string}"
end
+ def request_to_uri_and_body(request)
+ indirection = request.method == :search ? pluralize(request.indirection_name.to_s) : request.indirection_name.to_s
+ ["/#{request.environment.to_s}/#{indirection}/#{request.escaped_key}", request.query_string.sub(/^\?/,'')]
+ end
+
def indirection_method(http_method, indirection)
raise ArgumentError, "No support for http method #{http_method}" unless METHOD_MAP[http_method]