about summary refs log tree commit homepage
path: root/lib/mongrel.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mongrel.rb')
-rw-r--r--lib/mongrel.rb10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/mongrel.rb b/lib/mongrel.rb
index 4df0e3f..4e94f0a 100644
--- a/lib/mongrel.rb
+++ b/lib/mongrel.rb
@@ -9,7 +9,7 @@ $mongrel_debug_client = false
 require 'socket'
 require 'http11'
 require 'tempfile'
-require 'thread'
+require 'fastthread'
 require 'stringio'
 require 'mongrel/cgi'
 require 'mongrel/handlers'
@@ -200,6 +200,7 @@ module Mongrel
         @mpart_type, @mpart_boundary = @params['CONTENT_TYPE'].split(/;\s*/)
         if @mpart_type and @mpart_boundary and @mpart_boundary.include? "="
           @mpart_boundary = @mpart_boundary.split("=")[1].strip
+          STDERR.puts "boundary: #{@mpart_boundary}"
           @params['MULTIPART_TYPE'] = @mpart_type
           @params['MULTIPART_BOUNDARY'] = @mpart_boundary
           @search = BMHSearch.new(@mpart_boundary, 100)
@@ -230,11 +231,12 @@ module Mongrel
         read_body(remain, content_length, dispatcher)
       end
 
-      if @search
+      if @search and @body
+        STDERR.puts "number of boundaries: #{@search.nfound}"
         @body.rewind
         @search.pop.each do |boundary|
-          @body.seek(boundary)
-          STDERR.puts "BOUNDARY at #{boundary}: #{@body.readline}"
+          @body.seek(boundary - 2)
+          STDERR.puts "BOUNDARY at #{boundary}: #{@body.read(@mpart_boundary.length + 2)}"
         end
       end