diff options
-rw-r--r-- | lib/puppet/indirector/request.rb | 7 | ||||
-rwxr-xr-x | spec/unit/indirector/request.rb | 22 |
2 files changed, 28 insertions, 1 deletions
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index f1d02cead..194b9e031 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -60,6 +60,13 @@ class Puppet::Indirector::Request rescue => detail raise ArgumentError, "Could not understand URL %s: %s" % [source, detail.to_s] end + + # Just short-circuit these to full paths + if uri.scheme == "file" + @key = uri.path + return + end + @server = uri.host if uri.host # If the URI class can look up the scheme, it will provide a port, diff --git a/spec/unit/indirector/request.rb b/spec/unit/indirector/request.rb index 2476a3d7f..6169a09b4 100755 --- a/spec/unit/indirector/request.rb +++ b/spec/unit/indirector/request.rb @@ -77,6 +77,26 @@ describe Puppet::Indirector::Request do end describe "and the request key is a URI" do + describe "and the URI is a 'file' URI" do + before do + @request = Puppet::Indirector::Request.new(:ind, :method, "file:///my/file") + end + + it "should set the request key to the full file path" do @request.key.should == "/my/file" end + + it "should not set the protocol" do + @request.protocol.should be_nil + end + + it "should not set the port" do + @request.port.should be_nil + end + + it "should not set the server" do + @request.server.should be_nil + end + end + it "should set the protocol to the URI scheme" do Puppet::Indirector::Request.new(:ind, :method, "http://host/stuff").protocol.should == "http" end @@ -98,7 +118,7 @@ describe Puppet::Indirector::Request do Puppet::Indirector::Request.new(:ind, :method, "http://host/stuff").port.should == 80 end - it "should set the request key to the path from the URI" do + it "should set the request key to the unqualified path from the URI" do Puppet::Indirector::Request.new(:ind, :method, "http:///stuff").key.should == "stuff" end |