hello,

try running your script from the command line. but set the url and method 
environment variables first. on windows i do this:


set REQUEST_URI=/path
set REQUEST_METHOD=GET
ruby muscript.cgi .


this will allow you to avoid dealing with apache for a while, and will show 
more errors too.

konstantin


"Michael Schilling" <ruby / untiefe.de> wrote in message 
news:20060208203511.GA16112 / calvin.physik.uni-bielefeld.de...
> Hello everyone,
>
> I'm fairly new to ruby and wanted to write a very simple cgi program,
> which uploads a file and returns a converted file. Because it is so easy
> (and I want to learn about ruby) I tried to do it with the standard
> cgi.rb library. But I can't get the multipart_form (I need it for the
> file upload) to work right. Everything works fine using the normal form
> method, but with the multipart_form I always get an EOF Error 'no
> content body' in the apache log. As soon as there is any input from an
> multipart_form, an error occurs at: checkfile = CGI.new
>
> Below you'll find my code (I boiled it down to the important stuff) and 
> the
> corresponding part of my apache2 error_log. I searched the web, several
> mailing lists and the ruby docs, but couldn't find an answer. I also
> asked on #ruby-lang in freenode, but no one there knew the cgi.rb
> library very well.
>
> Any help, on why this server error is happening, is very much
> appreciated.
>
> Bye,
>     Michael <-- who hopes, that this is the right list for the question
>
>
>
> My code:
> ------------------------------------------------------------------
> #!/usr/bin/ruby -w
>
> require "cgi"
>
> # make_form create a very simple html form
> def make_form
>  make_form = CGI.new("html4")
>  make_form.out {
>    make_form.html {
>      make_form.body { "\n" +
> #        make_form.form{ "\n" +    # everything works using the normal 
> form
>        make_form.multipart_form{ "\n" +    # but not with multipart_form 
> to upload a file
>        make_form.file_field("filename",40,500000) + "\n" +
>        make_form.br +
>        make_form.submit("test it") + "\n"
>        }
>      }
>    }
>  }
> end
>
> # answer should show the filename of the uploaded file
> def answer(file_in)
>
>  answer = CGI.new("html4")
>  answer.out {
>    answer.html {
>      answer.body{ "\n" +
>      answer.p{ "This should be the filename:" + file_in + "\n" } +
>      answer.br
>      }
>    }
>  }
> end
>
>
>
> begin
>  checkfile = CGI.new
>  parameter = checkfile['filename']
> #  parameter = checkfile.params['filename'][0]  # this doesn't work either
>
> rescue
>  answer("ERROR: " + $!.to_s) # send eror message to browser if possible
> end
>
>
> # create form if no data was send to the script, otherwise answer
> if parameter == ""
>  make_form()
> else
>  answer(parameter.to_s)
> end
> ------------------------------------------------------------------
>
>
> Apache log:
> ------------------------------------------------------------------
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] 
> /usr/lib/ruby/1.8/cgi.rb:979:in `read_multipart', referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] : , referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] no content body, 
> referer: http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1]  (, referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] EOFError, referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] ), referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] \tfrom 
> /usr/lib/ruby/1.8/cgi.rb:1104:in `initialize_query', referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] \tfrom 
> /usr/lib/ruby/1.8/cgi.rb:2270:in `initialize', referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] \tfrom 
> /home/httpd/cgi-bin/multiform-test.rb:25:in `answer', referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] \tfrom 
> /home/httpd/cgi-bin/multiform-test.rb:52, referer: 
> http://localhost/cgi-bin/multiform-test.rb
> [Wed Feb 08 21:08:57 2006] [error] [client 191.168.1.1] Premature end of 
> script headers: multiform-test.rb, referer: 
> http://localhost/cgi-bin/multiform-test.rb
> ------------------------------------------------------------------
>
>
>
> -- 
> Michael Schilling
>
> eMail : ruby / untiefe.de
> URL  : http://glcu.sf.net/
>
>
> "Change my name I remain the same." - Moloko
>
>