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


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

def initialize(options = {})
end

Instance Method Details

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


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

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

#handle_response(http_response, rest_request, return_value) ⇒ Object


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

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"]))
  end
  [http_response, rest_request, return_value]
end

#handle_stream_complete(http_response, rest_request, return_value) ⇒ Object


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

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

#stream_response_handler(response) ⇒ Object


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

def stream_response_handler(response)
  nil
end