Skip to content

Commit

Permalink
fixed mount_path issue and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
aufflick committed Jun 25, 2007
1 parent 0978825 commit 309a7b3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Build.PL
Expand Up @@ -8,7 +8,7 @@ my $builder = Module::Build->new(
module_name => 'HTTP::Server::Brick',
license => 'perl',
dist_author => 'Mark Aufflick <mark@aufflick.com>',
dist_version => '0.0.7',
dist_version => '0.0.8',
requires => {
'Test::More' => 0,
'version' => 0,
Expand Down
3 changes: 3 additions & 0 deletions Changes
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion META.yml
@@ -1,6 +1,6 @@
---
name: HTTP-Server-Brick
version: 0.0.7
version: 0.0.8
author:
- 'Mark Aufflick <mark@aufflick.com>'
abstract: Simple pure perl http server for prototyping "in the style of" Ruby's WEBrick
Expand Down
4 changes: 2 additions & 2 deletions README
@@ -1,4 +1,4 @@
HTTP-Server-Brick version 0.0.7
HTTP-Server-Brick version 0.0.8

$Id$

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/HTTP/Server/Brick.pm
Expand Up @@ -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
Expand Down Expand Up @@ -433,7 +433,7 @@ sub _map_request {
if ($match_depth != $depth && !$map->[$match_depth]{$mount_path}{wildcard}) {
return;
}

return(
$map->[$match_depth]{$mount_path},
{
Expand Down
9 changes: 8 additions & 1 deletion t/serving.t
Expand Up @@ -81,6 +81,7 @@ $server->mount( '/test/wildcard_handler' => {
my ($req, $res) = @_;
$res->add_content("<html><body>
<p>Path info: $req->{path_info}</p>
<p>Mount path: $req->{mount_path}</p>
</body></html>");
1;
},
Expand Down Expand Up @@ -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: </p>!,
"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</p>!,
"Wildcard mounted handler root (mount path)", 'text/html' );

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

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

test_url(GET => "/test/redirect", RC_OK, qr!<html><body>No wildcards here</body></html>!,
"Fully qualified Redirect", 'text/html' );

Expand Down

0 comments on commit 309a7b3

Please sign in to comment.