Class: Chef::HTTP::APIVersions

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/http/api_versions.rb

Overview

An HTTP middleware to retrieve and store the Chef Server's minimum and maximum supported API versions.

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ APIVersions

Returns a new instance of APIVersions.



27
# File 'lib/chef/http/api_versions.rb', line 27

def initialize(options = {}); end

Instance Method Details

#handle_request(method, url, headers = {}, data = false) ⇒ Object



29
30
31
# File 'lib/chef/http/api_versions.rb', line 29

def handle_request(method, url, headers = {}, data = false)
  [method, url, headers, data]
end

#handle_response(http_response, rest_request, return_value) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/chef/http/api_versions.rb', line 33

def handle_response(http_response, rest_request, return_value)
  if http_response.code == "406"
    ServerAPIVersions.instance.reset!
  end
  if http_response.key?("x-ops-server-api-version")
    ServerAPIVersions.instance.set_versions(JSONCompat.parse(http_response["x-ops-server-api-version"]))
  else
    ServerAPIVersions.instance.unversioned!
  end
  [http_response, rest_request, return_value]
end

#handle_stream_complete(http_response, rest_request, return_value) ⇒ Object



49
50
51
# File 'lib/chef/http/api_versions.rb', line 49

def handle_stream_complete(http_response, rest_request, return_value)
  [http_response, rest_request, return_value]
end

#stream_response_handler(response) ⇒ Object



45
46
47
# File 'lib/chef/http/api_versions.rb', line 45

def stream_response_handler(response)
  nil
end