From 309a7b35df29bb5318cb788edeb6df42e6068fa9 Mon Sep 17 00:00:00 2001 From: Mark Aufflick Date: Mon, 25 Jun 2007 06:08:56 +0000 Subject: [PATCH] fixed mount_path issue and added test --- Build.PL | 2 +- Changes | 3 +++ META.yml | 2 +- README | 4 ++-- lib/HTTP/Server/Brick.pm | 4 ++-- t/serving.t | 9 ++++++++- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Build.PL b/Build.PL index 059b69c..2106469 100644 --- a/Build.PL +++ b/Build.PL @@ -8,7 +8,7 @@ my $builder = Module::Build->new( module_name => 'HTTP::Server::Brick', license => 'perl', dist_author => 'Mark Aufflick ', - dist_version => '0.0.7', + dist_version => '0.0.8', requires => { 'Test::More' => 0, 'version' => 0, diff --git a/Changes b/Changes index 44572cb..07f07f7 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,9 @@ Revision history for HTTP-Server-Brick $Id$ +0.0.8 Mon Jun 25 + fixed mount_path issue and added test + 0.0.7 Mon Jun 25 Minor pod changes diff --git a/META.yml b/META.yml index a3ab96b..704f255 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- name: HTTP-Server-Brick -version: 0.0.7 +version: 0.0.8 author: - 'Mark Aufflick ' abstract: Simple pure perl http server for prototyping "in the style of" Ruby's WEBrick diff --git a/README b/README index 3f88289..970811d 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -HTTP-Server-Brick version 0.0.7 +HTTP-Server-Brick version 0.0.8 $Id$ @@ -34,7 +34,7 @@ DEPENDENCIES BUGS AND LIMITATIONS -It's version 0.0.7 - there's bound to be some bugs! +It's version 0.0.8 - there's bound to be some bugs! The tests fail on windows due to forking limitations. I don't see any reason why the server itself won't work but I haven't tried it diff --git a/lib/HTTP/Server/Brick.pm b/lib/HTTP/Server/Brick.pm index 2196938..31c0116 100644 --- a/lib/HTTP/Server/Brick.pm +++ b/lib/HTTP/Server/Brick.pm @@ -296,7 +296,7 @@ sub _handle_dynamic_request { $res->base($match->{full_path}); # stuff the match info into the request - $req->{mount_path} = $submap->{mount_path}; + $req->{mount_path} = $match->{mount_path}; $req->{path_info} = $match->{path_info} ? '/' . $match->{path_info} : undef; # actually call the handler @@ -433,7 +433,7 @@ sub _map_request { if ($match_depth != $depth && !$map->[$match_depth]{$mount_path}{wildcard}) { return; } - + return( $map->[$match_depth]{$mount_path}, { diff --git a/t/serving.t b/t/serving.t index 7625296..c1f538e 100644 --- a/t/serving.t +++ b/t/serving.t @@ -81,6 +81,7 @@ $server->mount( '/test/wildcard_handler' => { my ($req, $res) = @_; $res->add_content("

Path info: $req->{path_info}

+

Mount path: $req->{mount_path}

"); 1; }, @@ -154,11 +155,17 @@ test_url(GET => "/test/non_wildcard_handler/foo", RC_NOT_FOUND, qr!Not Found!, "Handlers default to non-wildcard", ); test_url(GET => "/test/wildcard_handler", RC_OK, qr!Path info:

!, - "Wildcard mounted handler root", 'text/html' ); + "Wildcard mounted handler root (path info)", 'text/html' ); + +test_url(GET => "/test/wildcard_handler", RC_OK, qr!Mount path: /test/wildcard_handler

!, + "Wildcard mounted handler root (mount path)", 'text/html' ); test_url(GET => "/test/wildcard_handler/foo/bar", RC_OK, qr!Path info: /foo/bar

!, "Wildcard mounted handler with extra path", 'text/html' ); +test_url(GET => "/test/wildcard_handler/foo/bar", RC_OK, qr!Mount path: /test/wildcard_handler

!, + "Wildcard mounted handler with extra path (mount path)", 'text/html' ); + test_url(GET => "/test/redirect", RC_OK, qr!No wildcards here!, "Fully qualified Redirect", 'text/html' );