Class: Chef::HTTP::HTTPRequest
- Inherits:
-
Object
- Object
- Chef::HTTP::HTTPRequest
- Defined in:
- lib/chef/http/http_request.rb
Constant Summary collapse
- UA_COMMON =
"/#{::Chef::VERSION} (#{engine}-#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}; ohai-#{Ohai::VERSION}; #{RUBY_PLATFORM}; +#{ChefUtils::Dist::Org::WEBSITE})".freeze
- DEFAULT_UA =
"Chef Client" << UA_COMMON
- USER_AGENT =
"User-Agent".freeze
- ACCEPT_ENCODING =
"Accept-Encoding".freeze
- ENCODING_GZIP_DEFLATE =
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3".freeze
- GET =
"get".freeze
- PATCH =
"patch".freeze
- PUT =
"put".freeze
- POST =
"post".freeze
- DELETE =
"delete".freeze
- HEAD =
"head".freeze
- HTTPS =
"https".freeze
- SLASH =
"/".freeze
- HOST_LOWER =
"host".freeze
- URI_SCHEME_DEFAULT_PORT =
{ "http" => 80, "https" => 443 }.freeze
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#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.
Class Method Summary collapse
Instance Method Summary collapse
-
#call ⇒ Object
deprecated
Deprecated.
Call request on an HTTP client object instead.
- #config ⇒ Object
- #host ⇒ Object
-
#http_client ⇒ Object
deprecated
Deprecated.
Call request on an HTTP client object instead.
-
#initialize(method, url, req_body, base_headers = {}) ⇒ HTTPRequest
constructor
A new instance of HTTPRequest.
- #path ⇒ Object
- #port ⇒ Object
- #query ⇒ Object
- #uri_safe_host ⇒ Object
Constructor Details
#initialize(method, url, req_body, base_headers = {}) ⇒ HTTPRequest
Returns a new instance of HTTPRequest.
80 81 82 83 84 85 |
# File 'lib/chef/http/http_request.rb', line 80 def initialize(method, url, req_body, base_headers = {}) @method, @url = method, url @request_body = nil build_headers(base_headers) configure_http_request(req_body) end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
78 79 80 |
# File 'lib/chef/http/http_request.rb', line 78 def headers @headers end |
#http_request ⇒ Object (readonly)
Returns the value of attribute http_request.
78 79 80 |
# File 'lib/chef/http/http_request.rb', line 78 def http_request @http_request end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
78 79 80 |
# File 'lib/chef/http/http_request.rb', line 78 def method @method end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
78 79 80 |
# File 'lib/chef/http/http_request.rb', line 78 def url @url end |
Class Method Details
.user_agent ⇒ Object
74 75 76 |
# File 'lib/chef/http/http_request.rb', line 74 def self.user_agent @user_agent ||= DEFAULT_UA end |
.user_agent=(ua) ⇒ Object
70 71 72 |
# File 'lib/chef/http/http_request.rb', line 70 def self.user_agent=(ua) @user_agent = ua end |
Instance Method Details
#call ⇒ Object
Deprecated.
Call request on an HTTP client object instead.
108 109 110 111 112 113 114 115 |
# File 'lib/chef/http/http_request.rb', line 108 def call hide_net_http_bug do http_client.request(http_request) do |response| yield response if block_given? response end end end |
#config ⇒ Object
117 118 119 |
# File 'lib/chef/http/http_request.rb', line 117 def config Chef::Config end |
#host ⇒ Object
87 88 89 |
# File 'lib/chef/http/http_request.rb', line 87 def host @url.hostname end |
#http_client ⇒ Object
Deprecated.
Call request on an HTTP client object instead.
122 123 124 |
# File 'lib/chef/http/http_request.rb', line 122 def http_client @http_client ||= BasicClient.new(url).http_client end |
#path ⇒ Object
103 104 105 |
# File 'lib/chef/http/http_request.rb', line 103 def path @url.path.empty? ? SLASH : @url.path end |
#port ⇒ Object
95 96 97 |
# File 'lib/chef/http/http_request.rb', line 95 def port @url.port end |
#query ⇒ Object
99 100 101 |
# File 'lib/chef/http/http_request.rb', line 99 def query @url.query end |
#uri_safe_host ⇒ Object
91 92 93 |
# File 'lib/chef/http/http_request.rb', line 91 def uri_safe_host @url.host end |