HEAD request support was implemented in 2.6.x, and the internal API in the HTTP
handler changed in 2.7.x. So when the branches were merged together, HEAD
requests ended up using the wrong API without any visible merge conflicts or
spec failures. This fixes them to use the correct API.

Reviewed-By: Matt Robinson

Signed-off-by: Nick Lewis <[email protected]>
---
Local-branch: ticket/next/7103
 lib/puppet/network/http/handler.rb     |    8 ++++----
 spec/unit/network/http/handler_spec.rb |   18 +++++++-----------
 2 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/lib/puppet/network/http/handler.rb 
b/lib/puppet/network/http/handler.rb
index 2b9e81b..2c78a02 100644
--- a/lib/puppet/network/http/handler.rb
+++ b/lib/puppet/network/http/handler.rb
@@ -122,10 +122,10 @@ module Puppet::Network::HTTP::Handler
   end
 
   # Execute our head.
-  def do_head(indirection_request, request, response)
-    unless indirection_request.model.head(indirection_request.key, 
indirection_request.to_hash)
-      Puppet.info("Could not find #{indirection_request.indirection_name} for 
'#{indirection_request.key}'")
-      return do_exception(response, "Could not find 
#{indirection_request.indirection_name} #{indirection_request.key}", 404)
+  def do_head(indirection_name, key, params, request, response)
+    unless self.model(indirection_name).indirection.head(key, params)
+      Puppet.info("Could not find #{indirection_name} for '#{key}'")
+      return do_exception(response, "Could not find #{indirection_name} 
#{key}", 404)
     end
 
     # No need to set a response because no response is expected from a
diff --git a/spec/unit/network/http/handler_spec.rb 
b/spec/unit/network/http/handler_spec.rb
index 83969c5..c709d82 100755
--- a/spec/unit/network/http/handler_spec.rb
+++ b/spec/unit/network/http/handler_spec.rb
@@ -240,34 +240,30 @@ describe Puppet::Network::HTTP::Handler do
 
     describe "when performing head operation" do
       before do
-        @irequest = stub 'indirection_request', :method => :head, 
:indirection_name => "my_handler", :to_hash => {}, :key => "my_result", :model 
=> @model_class
+        @handler.stubs(:model).with("my_handler").returns(stub 'model', 
:indirection => @model_class)
+        @handler.stubs(:http_method).with(@request).returns("HEAD")
+        
@handler.stubs(:path).with(@request).returns("/production/my_handler/my_result")
+        @handler.stubs(:params).with(@request).returns({})
 
         @model_class.stubs(:head).returns true
       end
 
-      it "should use the indirection request to find the model class" do
-        @irequest.expects(:model).returns @model_class
-
-        @handler.do_head(@irequest, @request, @response)
-      end
-
       it "should use the escaped request key" do
         @model_class.expects(:head).with do |key, args|
           key == "my_result"
         end.returns true
-        @handler.do_head(@irequest, @request, @response)
+        @handler.process(@request, @response)
       end
 
       it "should not generate a response when a model head call succeeds" do
         @handler.expects(:set_response).never
-        @handler.do_head(@irequest, @request, @response)
+        @handler.process(@request, @response)
       end
 
       it "should return a 404 when the model head call returns false" do
-        @model_class.stubs(:name).returns "my name"
         @handler.expects(:set_response).with { |response, body, status| status 
== 404 }
         @model_class.stubs(:head).returns(false)
-        @handler.do_head(@irequest, @request, @response)
+        @handler.process(@request, @response)
       end
     end
 
-- 
1.7.4.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to