Apache2 + FastCGI + SSL: File upload fails with HTTPS

All,

I have run into a road block with my RoR project. The app works fine
without SSL but when I try to upload a file with the site running in
HTTPS, cgi.rb throws an EOFError:

[13/Mar/2006:23:05:48 :: 22982] Dispatcher failed to catch: bad content
body (EOFError) /usr/lib/ruby/1.8/cgi.rb:981:in read_multipartâ?? /usr/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/cgi_ext/raw_post_data_fix.rb:20:ininitialize_queryâ?? /usr/lib/ruby/1.8/cgi.rb:2270:in initializeâ?? (eval):16:ininitializeâ?? /usr/lib/ruby/1.8/fcgi.rb:600:in each_cgiâ?? /usr/lib/ruby/1.8/fcgi.rb:597:ineach_cgiâ??
/usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:52:in
process!â?? /usr/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/fcgi_handler.rb:22:inprocess!â?? /var/www/familygrove/public/dispatch.fcgi:26
almost killed by this error

My environment is Ubuntu 6.04, Ruby 1.8.2 and Rails 1.0.0.

Here’s the HEAD from cgi.rb read_multipart function:

def read_multipart(boundary, content_length)
  params = Hash.new([])
  boundary = "--" + boundary
  buf = ""
  bufsize = 10 * 1024

  # start multipart/form-data
  stdinput.binmode if defined? stdinput.binmode
  boundary_size = boundary.size + EOL.size
  content_length -= boundary_size
  status = stdinput.read(boundary_size)
  if nil == status
    raise EOFError, "no content body"
  elsif boundary + EOL != status
    raise EOFError, "bad content body"
  end

Are there any known issues with HTTPS upload and the above code block?
Anyone know of a workaround?

Thanks,

  • Zak

I saw some posts regarding a similar sounding problem with IE file
uploads. I just wanted to add that this problem occurs in IE 6.x as well
as Firefox 1.5.

Thanks for the reply.

Jon L. wrote:

I assume you meant 5.04.
Version 6.04 - Dapper Drake (to be released for production in April)

Are you using fcgid or fastcgi?
fcgid. I got it through apt-get. I added fcgid handler in .htaccess.
fcgid seems to work just fine, I can run all use cases, with or without
SSL. File upload is the only thing that fails, that’s only with SSL on.

Hi Zak,

I had a similar problem with fcgid on 5.04. I had to switch back to
fastcgi because I did not have time to troubleshoot it at that point.
I too would be interested to see any alternatives/work arounds,
especially as I would like to go to Dapper too when it is has been
released.

Regards,
Jon

I assume you meant 5.04.

Are you using fcgid or fastcgi?

Jon

Jon L. wrote:

I had a similar problem with fcgid on 5.04. I had to switch back to
fastcgi because I did not have time to troubleshoot it at that point.

Thanks Jon. Seems like Dapper has the same issue. I confirmed that the
problem is with fcgid, and not cgi.rb. I tried SSL with the default CGI
handler, slowness aside, file upload works just fine.

Are you using FastCGI with Apache 1.x? What is the easiest way to
install FastCGI with Apache2 without using fcgid, is there an apt
package? Can you point me in the right direction?

Thanks a bunch!

  • Zak