Class: Chef::Provider::RemoteFile::HTTP
- Inherits:
-
Object
- Object
- Chef::Provider::RemoteFile::HTTP
- Defined in:
- lib/chef/provider/remote_file/http.rb
Instance Attribute Summary collapse
-
#current_resource ⇒ Object
readonly
Returns the value of attribute current_resource.
-
#new_resource ⇒ Object
readonly
Returns the value of attribute new_resource.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #conditional_get_headers ⇒ Object
- #fetch ⇒ Object
- #headers ⇒ Object
-
#initialize(uri, new_resource, current_resource) ⇒ HTTP
constructor
Parse the uri into instance variables.
Constructor Details
#initialize(uri, new_resource, current_resource) ⇒ HTTP
Parse the uri into instance variables
36 37 38 39 40 |
# File 'lib/chef/provider/remote_file/http.rb', line 36 def initialize(uri, new_resource, current_resource) @uri = uri @new_resource = new_resource @current_resource = current_resource end |
Instance Attribute Details
#current_resource ⇒ Object (readonly)
Returns the value of attribute current_resource.
33 34 35 |
# File 'lib/chef/provider/remote_file/http.rb', line 33 def current_resource @current_resource end |
#new_resource ⇒ Object (readonly)
Returns the value of attribute new_resource.
32 33 34 |
# File 'lib/chef/provider/remote_file/http.rb', line 32 def new_resource @new_resource end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
31 32 33 |
# File 'lib/chef/provider/remote_file/http.rb', line 31 def uri @uri end |
Instance Method Details
#conditional_get_headers ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/chef/provider/remote_file/http.rb', line 46 def conditional_get_headers cache_control_headers = {} if last_modified = cache_control_data.mtime and want_mtime_cache_control? cache_control_headers["if-modified-since"] = last_modified end if etag = cache_control_data.etag and want_etag_cache_control? cache_control_headers["if-none-match"] = etag end Chef::Log.debug("Cache control headers: #{cache_control_headers.inspect}") cache_control_headers end |
#fetch ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/chef/provider/remote_file/http.rb', line 58 def fetch http = Chef::HTTP::Simple.new(uri, http_client_opts) tempfile = http.streaming_request(uri, headers) if tempfile update_cache_control_data(tempfile, http.last_response) tempfile.close end tempfile end |
#headers ⇒ Object
42 43 44 |
# File 'lib/chef/provider/remote_file/http.rb', line 42 def headers conditional_get_headers.merge(new_resource.headers) end |