[poe-commits] SF.net SVN: poe: [1951] trunk/poe/lib/POE/Filter
Brought to you by:
rcaputo
From: <tek...@us...> - 2006-05-01 18:31:44
|
Revision: 1951 Author: teknikill Date: 2006-05-01 11:31:32 -0700 (Mon, 01 May 2006) ViewCVS: http://svn.sourceforge.net/poe/?rev=1951&view=rev Log Message: ----------- added support in HTTPD filter for 'options' requests, and added test for it Modified Paths: -------------- trunk/poe/lib/POE/Filter/HTTPD.pm trunk/poe/tests/10_units/05_filters/03_http.t Modified: trunk/poe/lib/POE/Filter/HTTPD.pm =================================================================== --- trunk/poe/lib/POE/Filter/HTTPD.pm 2006-05-01 03:52:38 UTC (rev 1950) +++ trunk/poe/lib/POE/Filter/HTTPD.pm 2006-05-01 18:31:32 UTC (rev 1951) @@ -78,7 +78,7 @@ my @dump; my $offset = 0; - $stream = join("", @$stream); + $stream = $self->[BUFFER].join("", @$stream); while (length $stream) { my $line = substr($stream, 0, 16); substr($stream, 0, 16) = ''; @@ -222,6 +222,13 @@ ) ]; } + elsif ($method eq 'OPTIONS') { + $self->[FINISH]++; + # OPTIONS requests can have an optional content length + # See http://www.faqs.org/rfcs/rfc2616.html, section 9.2 + delete $self->[HEADER]; + return [$r]; + } else { return [ $self->build_error(RC_LENGTH_REQUIRED, "No content length found.") Modified: trunk/poe/tests/10_units/05_filters/03_http.t =================================================================== --- trunk/poe/tests/10_units/05_filters/03_http.t 2006-05-01 03:52:38 UTC (rev 1950) +++ trunk/poe/tests/10_units/05_filters/03_http.t 2006-05-01 18:31:32 UTC (rev 1951) @@ -15,7 +15,7 @@ eval " use Test::More skip_all => 'HTTP::Request is needed for these tests.' "; } else { eval { - eval " use Test::More tests => 57; "; + eval " use Test::More tests => 64; "; use_ok('POE::Filter::HTTPD'); } } @@ -250,3 +250,30 @@ } } # }}} + +{ # options request {{{ + + my $request = HTTP::Request->new('OPTIONS', '*'); + $request->protocol('HTTP/1.0'); + + my $filter = POE::Filter::HTTPD->new(); + + my $data; + eval { $data = $filter->get([ $request->as_string ]); }; + ok(!$@, 'options: get() throws no exceptions'); + ok(defined $data, "options: get() returns something"); + is(ref $data, 'ARRAY', 'options: get() returns list of requests'); + is(scalar @$data, 1, 'options: get() returned single request'); + + my $req = shift @$data; + + is(ref $req, 'HTTP::Request', + 'options: get() returns HTTP::Request object'); + + is($req->method, 'OPTIONS', + 'options: HTTP::Request object contains proper HTTP method'); + + is($req->url, '*', + 'options: HTTP::Request object contains proper URI'); + +} # }}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |