Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Don't restrict parsing the request body to PUT and POST requests #23

Merged
merged 1 commit into from

3 participants

@monken

I use Twiggy as a proxy in front of ElasticSearch. ES allows both GET and DELETE requests with a request body. I don't see a reason why Twiggy shouldn't support this as well.

@monken

Not sure what you are saying, but from the link I'd say you are in favor of this patch :-)

@chipdude

Well, I mostly wanted to bring the facts in. The one thing that truly surprised me was "the presence of a message-body is signaled by the inclusion of a Content-Length or Transfer-Encoding header (section 4.3)".

I figured that a message-body could appear in any message, with an assumed text/plain type. But perhaps HTTP 1.1's pipeline design required more explicit indications.

So yes: If those headers are present then there is a message body, and if there is a body then it should be parsed. If those headers are not present, though, I wouldn't bother.

@miyagawa miyagawa merged commit c992337 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 1 deletion.
  1. +2 −0  Changes
  2. +1 −1  lib/Twiggy/Server.pm
View
2  Changes
@@ -1,5 +1,7 @@
Revision history for Perl extension Twiggy
+ - Don't restrict parsing the request body to PUT and POST requests
+
0.1010 Mon Jan 17 17:04:14 PST 2011
- Returning CondVar as a PSGI response is deprecated. Will be removed in the next release
View
2  lib/Twiggy/Server.pm
@@ -292,7 +292,7 @@ sub _run_app {
my($self, $app, $env, $sock) = @_;
unless ($env->{'psgi.input'}) {
- if ($env->{CONTENT_LENGTH} && $env->{REQUEST_METHOD} =~ /^(?:POST|PUT)$/) {
+ if ($env->{CONTENT_LENGTH}) {
$self->_read_chunk($sock, $env->{CONTENT_LENGTH}, sub {
my ($data) = @_;
open my $input, '<', \$data;
Something went wrong with that request. Please try again.