Class: Chef::REST::RESTRequest
- Inherits:
-
Object
- Object
- Chef::REST::RESTRequest
- Defined in:
- lib/chef/rest/rest_request.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#http_request ⇒ Object
readonly
Returns the value of attribute http_request.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #call ⇒ Object
- #config ⇒ Object
- #host ⇒ Object
-
#initialize(method, url, req_body, base_headers = {}) ⇒ RESTRequest
constructor
A new instance of RESTRequest.
- #path ⇒ Object
- #port ⇒ Object
- #query ⇒ Object
Constructor Details
#initialize(method, url, req_body, base_headers = {}) ⇒ RESTRequest
Returns a new instance of RESTRequest.
33 34 35 36 37 38 39 40 |
# File 'lib/chef/rest/rest_request.rb', line 33 def initialize(method, url, req_body, base_headers={}) @method, @url = method, url @request_body = nil @cookies = CookieJar.instance configure_http_client build_headers(base_headers) configure_http_request(req_body) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
31 32 33 |
# File 'lib/chef/rest/rest_request.rb', line 31 def headers @headers end |
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
31 32 33 |
# File 'lib/chef/rest/rest_request.rb', line 31 def http_client @http_client end |
#http_request ⇒ Object (readonly)
Returns the value of attribute http_request.
31 32 33 |
# File 'lib/chef/rest/rest_request.rb', line 31 def http_request @http_request end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
31 32 33 |
# File 'lib/chef/rest/rest_request.rb', line 31 def method @method end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
31 32 33 |
# File 'lib/chef/rest/rest_request.rb', line 31 def url @url end |
Instance Method Details
#call ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/chef/rest/rest_request.rb', line 58 def call hide_net_http_bug do http_client.request(http_request) do |response| (response) yield response if block_given? response end end end |
#config ⇒ Object
68 69 70 |
# File 'lib/chef/rest/rest_request.rb', line 68 def config Chef::Config end |
#host ⇒ Object
42 43 44 |
# File 'lib/chef/rest/rest_request.rb', line 42 def host @url.host end |
#path ⇒ Object
54 55 56 |
# File 'lib/chef/rest/rest_request.rb', line 54 def path @url.path.empty? ? "/" : @url.path end |
#port ⇒ Object
46 47 48 |
# File 'lib/chef/rest/rest_request.rb', line 46 def port @url.port end |
#query ⇒ Object
50 51 52 |
# File 'lib/chef/rest/rest_request.rb', line 50 def query @url.query end |