Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add REQUEST_URI to response

  • Loading branch information...
commit 9f37ec13cedf27a687f5bc048b5cf7c2d7868a33 1 parent a476957
@kazuho authored
Showing with 12 additions and 3 deletions.
  1. +3 −0  Changes
  2. +2 −0  XS.xs
  3. +1 −1  lib/HTTP/Parser/XS.pm
  4. +6 −2 t/01simple.t
View
3  Changes
@@ -1,5 +1,8 @@
Revision history for Perl extension HTTP::Parser::XS.
+0.03 Fri Oct 02 06:30:00 2009
+ - add REQUEST_URI to response
+
0.02 Tue Sep 29 12:55:00 2009
- url-decode PATH_INFO
View
2  XS.xs
@@ -126,6 +126,8 @@ CODE:
hv_store(env, "REQUEST_METHOD", sizeof("REQUEST_METHOD") - 1,
newSVpvn(method, method_len), 0);
+ hv_store(env, "REQUEST_URI", sizeof("REQUEST_URI") - 1,
+ newSVpvn(path, path_len), 0);
hv_store(env, "SCRIPT_NAME", sizeof("SCRIPT_NAME") - 1, newSVpvn("", 0), 0);
question_at = find_ch(path, path_len, '?');
if (store_url_decoded(env, "PATH_INFO", sizeof("PATH_INFO") - 1, path,
View
2  lib/HTTP/Parser/XS.pm
@@ -11,7 +11,7 @@ our %EXPORT_TAGS = (
our @EXPORT_OK = @{$EXPORT_TAGS{all}};
our @EXPORT = ();
-our $VERSION = '0.02';
+our $VERSION = '0.03';
require XSLoader;
XSLoader::load('HTTP::Parser::XS', $VERSION);
View
8 t/01simple.t
@@ -12,13 +12,14 @@ eval {
ok($@, '"croak if second param is not a hashref');
undef $@;
-$req = "GET /abc?x=y HTTP/1.0\r\n\r\n";
+$req = "GET /abc?x=%79 HTTP/1.0\r\n\r\n";
%env = ();
is(parse_http_request($req, \%env), length($req), 'simple get');
is_deeply(\%env, {
PATH_INFO => '/abc',
- QUERY_STRING => 'x=y',
+ QUERY_STRING => 'x=%79',
REQUEST_METHOD => "GET",
+ REQUEST_URI => '/abc?x=%79',
SCRIPT_NAME => '',
SERVER_PROTOCOL => 'HTTP/1.0',
}, 'result of GET /');
@@ -40,6 +41,7 @@ is_deeply(\%env, {
HTTP_USER_AGENT => 'hoge',
PATH_INFO => '/hoge',
REQUEST_METHOD => "POST",
+ REQUEST_URI => '/hoge',
QUERY_STRING => '',
SCRIPT_NAME => '',
SERVER_PROTOCOL => 'HTTP/1.1',
@@ -61,6 +63,7 @@ is_deeply(\%env, {
PATH_INFO => '/',
QUERY_STRING => '',
REQUEST_METHOD => 'GET',
+ REQUEST_URI => '/',
SCRIPT_NAME => '',
SERVER_PROTOCOL => 'HTTP/1.0',
}, 'multiline');
@@ -74,6 +77,7 @@ is(parse_http_request($req, \%env), length($req), 'url-encoded');
is_deeply(\%env, {
PATH_INFO => '/a b',
REQUEST_METHOD => 'GET',
+ REQUEST_URI => '/a%20b',
QUERY_STRING => '',
SCRIPT_NAME => '',
SERVER_PROTOCOL => 'HTTP/1.0',
Please sign in to comment.
Something went wrong with that request. Please try again.