Method: Puppet::Indirector::REST#find

Defined in:
lib/vendor/puppet/indirector/rest.rb

#find(request) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/vendor/puppet/indirector/rest.rb', line 116

def find(request)
  uri, body = request_to_uri_and_body(request)
  uri_with_query_string = "#{uri}?#{body}"
  # 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_post(request, uri, body, headers)
  else
    http_get(request, uri_with_query_string, headers)
  end
  result = deserialize response
  result.name = request.key if result.respond_to?(:name=)
  result
end