[Bps-public-commit] HTTP-Server-Simple branch, master, updated. 0.50-4-ga50ae6c

? sunnavy sunnavy at bestpractical.com
Mon Sep 14 13:25:20 EDT 2015


The branch, master has been updated
       via  a50ae6c28e4b2f73992e7d55f3634dab44259b1c (commit)
      from  ce40384d3f1570b38b0531f6d701fecbbbaff33f (commit)

Summary of changes:
 lib/HTTP/Server/Simple.pm | 6 +++---
 t/04cgi.t                 | 5 +++--
 2 files changed, 6 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit a50ae6c28e4b2f73992e7d55f3634dab44259b1c
Author: James McCoy <vega.james at gmail.com>
Date:   Wed Mar 12 14:03:50 2014 -0400

    Recognize OPTIONS as a valid HTTP method
    
    As noted in <https://rt.cpan.org/Public/Bug/Display.html?id=82740>,
    OPTIONS requests are required for non-trivial cross-site requests.
    Dancer uses HTTP::Server::Simple and therefore cannot support a common
    type of AJAX/REST request without this change.
    
    Signed-off-by: James McCoy <vega.james at gmail.com>

diff --git a/lib/HTTP/Server/Simple.pm b/lib/HTTP/Server/Simple.pm
index 89b43e4..b905872 100644
--- a/lib/HTTP/Server/Simple.pm
+++ b/lib/HTTP/Server/Simple.pm
@@ -765,15 +765,15 @@ sub bad_request {
 
 Given a candidate HTTP method in $method, determine if it is valid.
 Override if, for example, you'd like to do some WebDAV.  The default
-implementation only accepts C<GET>, C<POST>, C<HEAD>, C<PUT>, C<PATCH>
-and C<DELETE>.
+implementation only accepts C<GET>, C<POST>, C<HEAD>, C<PUT>, C<PATCH>,
+C<DELETE> and C<OPTIONS>.
 
 =cut 
 
 sub valid_http_method {
     my $self   = shift;
     my $method = shift or return 0;
-    return $method =~ /^(?:GET|POST|HEAD|PUT|PATCH|DELETE)$/;
+    return $method =~ /^(?:GET|POST|HEAD|PUT|PATCH|DELETE|OPTIONS)$/;
 }
 
 =head1 AUTHOR
diff --git a/t/04cgi.t b/t/04cgi.t
index 20655aa..f731db4 100644
--- a/t/04cgi.t
+++ b/t/04cgi.t
@@ -34,10 +34,10 @@ my %envvars=(
 if ($^O eq 'freebsd' && `sysctl -n security.jail.jailed` == 1) {
     delete @methods{qw(url server_name)};
     delete @envvars{qw(SERVER_URL SERVER_NAME REMOTE_ADDR)};
-    plan tests => 46;
+    plan tests => 47;
 }
 else {
-    plan tests => 61;
+    plan tests => 62;
 }
 
 {
@@ -57,6 +57,7 @@ else {
       [["PUT / HTTP/1.1","Content-Length: 0",""], '/NOFILE/', '[PUT] no file'],
       [["DELETE / HTTP/1.1",""], '/NOFILE/', '[DELETE] no file'],
       [["PATCH / HTTP/1.1","Content-Length: 0",""], '/NOFILE/', '[PATCH] no file'],
+      [["OPTIONS / HTTP/1.1","Content-Length: 0",""], '/NOFILE/', '[OPTIONS] no file'],
   );
   foreach my $message_test (@message_tests) {
     my ($message, $expected, $description) = @$message_test;

-----------------------------------------------------------------------


More information about the Bps-public-commit mailing list