diff options
author | Luke Kanies <luke@madstop.com> | 2008-08-23 18:15:56 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-08-26 22:40:39 -0700 |
commit | f5ba99fd24ce2e7cdba7c81153c46df14811d193 (patch) | |
tree | 909d98edc1a711cbaa5eb19cac420ef6d919666a | |
parent | a215abaef97ea1fb0187f46c5e6a880ff1d29036 (diff) | |
download | puppet-f5ba99fd24ce2e7cdba7c81153c46df14811d193.tar.gz puppet-f5ba99fd24ce2e7cdba7c81153c46df14811d193.tar.xz puppet-f5ba99fd24ce2e7cdba7c81153c46df14811d193.zip |
Special-casing 'file' URIs in the indirection requests.
These just get converted to full file paths, since
we know they will never pass over the wire.
Signed-off-by: Luke Kanies <luke@madstop.com>
-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 |