Created
May 5, 2011 19:43
-
-
Save miyagawa/957749 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/Server/PSGI.pm b/lib/Mojo/Server/PSGI.pm | |
index aa9b09c..1740d6c 100644 | |
--- a/lib/Mojo/Server/PSGI.pm | |
+++ b/lib/Mojo/Server/PSGI.pm | |
@@ -21,10 +21,14 @@ sub run { | |
$tx->local_port($env->{SERVER_PORT}); | |
# Request body | |
+ my $cl = $env->{CONTENT_LENGTH}; | |
while (!$req->is_done) { | |
- my $read = $env->{'psgi.input'}->read(my $buffer, CHUNK_SIZE, 0); | |
+ my $chunk = ($cl && $cl < CHUNK_SIZE) ? $cl : CHUNK_SIZE; | |
+ my $read = $env->{'psgi.input'}->read(my $buffer, $chunk, 0); | |
last unless $read; | |
$req->parse($buffer); | |
+ $cl -= $read; | |
+ last if $cl <= 0; | |
} | |
# Handle |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment