diff options
author | Andrey Stikheev <andrey.stikheev@gmail.com> | 2009-10-25 13:11:35 +0300 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-10-25 14:06:14 -0700 |
commit | bbca687b8ce0c0cbf10407f2aaf87e18bfc311e5 (patch) | |
tree | d5af9c04bda396328d3dd47e65cdc69f227d3703 /lib/unicorn/tee_input.rb | |
parent | 3a624fe924b8f3a9dfdcf5222ed6d1968f462468 (diff) | |
download | unicorn-bbca687b8ce0c0cbf10407f2aaf87e18bfc311e5.tar.gz |
Under FreeBSD writing to the file in sync mode does not change current position, so change position to the end of the file. Without this patch multipart post requests with large data (image uploading) does not work correctly: Status: 500 Internal Server Error bad content body /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/utils.rb:347:in `parse_multipart' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/utils.rb:319:in `loop' /usr/local/lib/ruby/gems/1.8/gems/rack-1.0.0/lib/rack/utils.rb:319:in `parse_multipart' File position behavior under FreeBSD : ruby -v ruby 1.8.7 (2009-04-08 patchlevel 160) [i386-freebsd7] irb(main):001:0> b = File.new("abc", "w+") => #<File:abc> irb(main):002:0> b.sync = true => true irb(main):004:0> b.write("abc") => 3 irb(main):005:0> b.pos => 0 Acked-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'lib/unicorn/tee_input.rb')
-rw-r--r-- | lib/unicorn/tee_input.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 188e2ea..7e77cdf 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -131,6 +131,7 @@ module Unicorn begin if parser.filter_body(dst, socket.readpartial(length, buf)).nil? @tmp.write(dst) + @tmp.seek(0, IO::SEEK_END) # workaround FreeBSD/OSX + MRI 1.8.x bug return dst end rescue EOFError |