[Bps-public-commit] HTTP-Server-Simple branch, master, updated. 0.44-4-gd755a1c
Jason May
jasonmay at bestpractical.com
Wed Nov 30 16:16:00 EST 2011
The branch, master has been updated
via d755a1cd5adf12cd4b027572f25df9f90f0661e3 (commit)
via 0257274c55289e2ec73f7ab1707ad6a294be8ba5 (commit)
from 20c1d349108f6fc54d0bd251dd5b0d1605e5f5ae (commit)
Summary of changes:
lib/HTTP/Server/Simple.pm | 6 +++---
t/04cgi.t | 18 +++++++++++++++---
2 files changed, 18 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit 0257274c55289e2ec73f7ab1707ad6a294be8ba5
Author: David Precious <davidp at preshweb.co.uk>
Date: Mon Nov 28 11:33:57 2011 +0000
Recognise PATCH as a valid HTTP verb.
This is defined in RFC5789: http://tools.ietf.org/html/rfc5789
This is in active use by GitHub's v3 API, among others.
As a quick overview for anyone unfamilar with PATCH, it's basically a
partial-PUT, passing only the changes - for instance, let's say you wanted to
update a customer's contact email address, you might send a PATCH request to
`/customer/42/contactdetails` with a JSON payload describing just the parts
which have changed, for instance `{ email: 'bob at example.com' }`.
diff --git a/lib/HTTP/Server/Simple.pm b/lib/HTTP/Server/Simple.pm
index 05dbe60..37ddf6b 100644
--- a/lib/HTTP/Server/Simple.pm
+++ b/lib/HTTP/Server/Simple.pm
@@ -701,15 +701,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>, and
-C<DELETE>.
+implementation only accepts C<GET>, C<POST>, C<HEAD>, C<PUT>, C<PATCH>
+and C<DELETE>.
=cut
sub valid_http_method {
my $self = shift;
my $method = shift or return 0;
- return $method =~ /^(?:GET|POST|HEAD|PUT|DELETE)$/;
+ return $method =~ /^(?:GET|POST|HEAD|PUT|PATCH|DELETE)$/;
}
=head1 AUTHOR
commit d755a1cd5adf12cd4b027572f25df9f90f0661e3
Author: Jason May <jasonmay at bestpractical.com>
Date: Wed Nov 30 09:26:47 2011 -0500
Test that PATCH and other supported request methods get proper responses
diff --git a/t/04cgi.t b/t/04cgi.t
index 83a41cf..370d98a 100644
--- a/t/04cgi.t
+++ b/t/04cgi.t
@@ -32,10 +32,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 => 50;
+ plan tests => 55;
}
else {
- plan tests => 55;
+ plan tests => 60;
}
{
@@ -48,7 +48,19 @@ else {
like($pid, '/^-?\d+$/', 'pid is numeric');
select(undef,undef,undef,0.2); # wait a sec
- like(fetch("GET / HTTP/1.1",""), '/NOFILE/', 'no file');
+ my @message_tests = (
+ [["GET / HTTP/1.1",""], '/NOFILE/', '[GET] no file'],
+ [["POST / HTTP/1.1","Content-Length: 0",""], '/NOFILE/', '[POST] no file'],
+ [["HEAD / HTTP/1.1",""], '/NOFILE/', '[HEAD] no file'],
+ [["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'],
+ );
+ foreach my $message_test (@message_tests) {
+ my ($message, $expected, $description) = @$message_test;
+ like(fetch(@$message), $expected, $description);
+ select(undef,undef,undef,0.2); # wait a sec
+ }
foreach my $method (keys(%methods)) {
next unless defined $methods{$method};
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list