summaryrefslogtreecommitdiff
path: root/lib/chef/rest.rb
diff options
context:
space:
mode:
authordanielsdeleo <dan@getchef.com>2015-03-27 17:51:36 -0700
committerdanielsdeleo <dan@getchef.com>2015-04-01 13:35:01 -0700
commit8b42ac0374fb075fbcb21df73742e81e69d9bf6f (patch)
tree89866faf81354bab896ea964751b46b81458540e /lib/chef/rest.rb
parent5581644c881e34f16d3f82d40636e88bb6a2ea97 (diff)
downloadchef-8b42ac0374fb075fbcb21df73742e81e69d9bf6f.tar.gz
Extract Chef Zero code out to chef zero, re-enable socket listening
Diffstat (limited to 'lib/chef/rest.rb')
-rw-r--r--lib/chef/rest.rb30
1 files changed, 4 insertions, 26 deletions
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb
index 2b1f2044c4..855608385d 100644
--- a/lib/chef/rest.rb
+++ b/lib/chef/rest.rb
@@ -38,29 +38,6 @@ require 'chef/exceptions'
require 'chef/platform/query_helpers'
require 'chef/http/remote_request_id'
-module ChefZero
- # TODO: this needs to wrap all the things in a mutex
- class Socketless
-
- include Singleton
-
- def initialize()
- reset!
- end
-
- def reset!(options={})
- @server = ChefZero::Server.new(options)
- # TODO: make this public or whatever we need to do so we don't need #send
- @app = @server.send(:app)
- end
-
- def request(rack_env)
- @app.call(rack_env)
- end
-
- end
-end
-
class Chef
class SocketlessChefZeroClient
@@ -149,7 +126,7 @@ class Chef
end
def port
- "no port"
+ @url.port
end
# request, response = client.request(method, url, body, headers) {|r| r.read_body }
@@ -162,11 +139,12 @@ class Chef
r["PATH_INFO"] = url.path
r["QUERY_STRING"] = url.query
r["SERVER_NAME"] = "localhost"
- r["SERVER_PORT"] = ""
+ r["SERVER_PORT"] = url.port
+ r["HTTP_HOST"] = "localhost:#{url.port}"
r["rack.url_scheme"] = "chefzero"
r["rack.input"] = StringIO.new(body_str)
- res = ChefZero::Socketless.instance.request(r)
+ res = ChefZero::SocketlessServerMap.request(port, r)
net_http_response = to_net_http(res[0], res[1], res[2])