[macruby-changes] [4277] ControlTower/trunk/lib/control_tower/rack_socket.rb
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jun 25 02:45:04 PDT 2010
Revision: 4277
http://trac.macosforge.org/projects/ruby/changeset/4277
Author: joshua.ballanco at apple.com
Date: 2010-06-25 02:44:59 -0700 (Fri, 25 Jun 2010)
Log Message:
-----------
-[NSFileHandle availableData] is not quite the same as IO#readpartial
Modified Paths:
--------------
ControlTower/trunk/lib/control_tower/rack_socket.rb
Modified: ControlTower/trunk/lib/control_tower/rack_socket.rb
===================================================================
--- ControlTower/trunk/lib/control_tower/rack_socket.rb 2010-06-25 09:03:38 UTC (rev 4276)
+++ ControlTower/trunk/lib/control_tower/rack_socket.rb 2010-06-25 09:44:59 UTC (rev 4277)
@@ -85,18 +85,21 @@
parser = ::CTParser.new
data = NSMutableData.alloc.init
parsing_headers = true # Parse headers first
+ nread = 0
content_length = 0
content_uploaded = 0
connection_handle = NSFileHandle.alloc.initWithFileDescriptor(connection.fileno)
$stdout.puts "Started parsing at #{Time.now.to_f}"
while (parsing_headers || content_uploaded < content_length) do
- # Read the availableData on the socket and rescue any errors:
+ # Read the availableData on the socket and give up if there's nothing
incoming_bytes = connection_handle.availableData
+ return nil if incoming_bytes.length == 0
# Until the headers are done being parsed, we'll parse them
if parsing_headers
data.appendData(incoming_bytes)
+ $stdout.puts "Calling parser with #{data.length} bytes starting at #{nread}"
nread = parser.parseData(data, forEnvironment: env, startingAt: nread)
if parser.finished
$stdout.puts "Finished parsing headers at #{Time.now.to_f}"
@@ -122,9 +125,9 @@
env['rack.input'].each { |upload_data| body << upload_data.to_str }
env['rack.input'] = body
end
- # Returning what we've got...
- return env
end
+ # Returning what we've got...
+ return env
end
end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100625/ae38d4fa/attachment.html>
More information about the macruby-changes
mailing list