summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-05-10 18:54:51 -0700
committerEric Wong <normalperson@yhbt.net>2009-05-10 21:44:25 -0700
commitff3194db3ac25ba8936c06f3815dcbbdb67e04ff (patch)
tree814d310ba7c1be44251d53c9cd36207fb574b07d
parentba4e7252d4bc336a78caa2aec4ac3420d8ce46a4 (diff)
This allows alternative I/O implementations to be easier
to use with Unicorn...
-rw-r--r--lib/unicorn/http_request.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index c356576..29503f5 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -113,15 +113,13 @@ module Unicorn
           StringIO.new : Tempfile.new('unicorn')
 
       body.binmode
-      body.sync = true
-      body.syswrite(http_body)
+      body.write(http_body)
 
       # Some clients (like FF1.0) report 0 for body and then send a body.
       # This will probably truncate them but at least the request goes through
       # usually.
       read_body(socket, remain, body) if remain > 0
       body.rewind
-      body.sysseek(0) if body.respond_to?(:sysseek)
 
       # in case read_body overread because the client tried to pipeline
       # another request, we'll truncate it.  Again, we don't do pipelining
@@ -136,10 +134,10 @@ module Unicorn
     # of the body that has been read to be in the PARAMS['rack.input']
     # already.  It will return true if successful and false if not.
     def read_body(socket, remain, body)
-      while remain > 0
-        # writes always write the requested amount on a POSIX filesystem
-        remain -= body.syswrite(socket.readpartial(Const::CHUNK_SIZE, BUFFER))
-      end
+      begin
+        # write always writes the requested amount on a POSIX filesystem
+        remain -= body.write(socket.readpartial(Const::CHUNK_SIZE, BUFFER))
+      end while remain > 0
     rescue Object => e
       @logger.error "Error reading HTTP body: #{e.inspect}"