File tree Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Expand file tree Collapse file tree 3 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ Revision history for Dancer
1818 (Yanick Champoux, reported by sciurius)
1919 * GH #954: don't die on autoflush for older perls.
2020 (Yanick Champoux, reported by metateck and David Golden)
21+ * GH #950: Dancer::Test functions now populate REQUEST_URI.
22+ (Yanick Champoux, reported by Sören Kornetzki)
2123
2224 [ DOCUMENTATION ]
2325 * GH #942: simpilify the Apache deployment docs for cgi/fcgi.
Original file line number Diff line number Diff line change @@ -361,6 +361,17 @@ sub dancer_response {
361361 $extra_env -> {' CONTENT_TYPE' } = $headers -> header(' Content-Type' );
362362 }
363363
364+ # fake the REQUEST_URI
365+ # TODO deal with the params
366+ unless ( $extra_env -> {REQUEST_URI } ) {
367+ $extra_env -> {REQUEST_URI } = $path ;
368+ if ( $method eq ' GET' and $params ) {
369+ $extra_env -> {REQUEST_URI } .=
370+ ' ?' . join ' &' , map { join ' =' , $_ , $params -> {$_ } }
371+ sort keys %$params ;
372+ }
373+ }
374+
364375 my $request = Dancer::Request-> new_for_request(
365376 $method => $path ,
366377 $params , $body , $headers , $extra_env
Original file line number Diff line number Diff line change 1+ use strict;
2+ use warnings;
3+
4+ use Test::More tests => 5;
5+
6+ use Dancer ' :tests' ;
7+ use Dancer::Test;
8+
9+ get ' /uri_base' => sub { request-> uri_base };
10+ get ' /uri' => sub { request-> uri };
11+ get ' /path' => sub { request-> path };
12+
13+ response_content_is ' /uri_base' => ' http://localhost' ;
14+ response_content_is ' /uri' => ' /uri' ;
15+ response_content_is ' /uri?with=params' => ' /uri?with=params' ;
16+ response_content_is ' /path' => ' /path' ;
17+ response_content_is ' /path?with=params' => ' /path' ;
18+
You can’t perform that action at this time.
0 commit comments