From: Kevin Layman Date: 2007-03-16T04:44:33+09:00 Subject: Windows cgihandler Error: Premature end of script headers I've downloaded and installed Ruby (v1.8.5) w/the latest Windows installer and am trying to run some cgi's per these examples: http://microjet.ath.cx/webrickguide/html/CGIHandler.html I keep getting HTTP 500 - Internal server error, and in the Ruby command line PREMATURE END OF SCRIPT HEADERS. I've got the path to the Ruby executable in test.cgi, and the next line outputs a valid header, and this cgi will execute correctly when run by Webrick directly. Programs are below. test.cgi: #!g:\ruby\bin\ruby.exe print "Content-type: text/plain\r\n\r\n" ENV.keys.sort.each{|k| puts "#{k} ==> #{ENV[k]}"} cgi_handler.rb: require 'webrick' include WEBrick # let's import the namespace so # I don't have to keep typing # WEBrick:: in this documentation. def start_webrick(config = {}) # always listen on port 8080 config.update(:Port => 8080) server = HTTPServer.new(config) yield server if block_given? ['INT', 'TERM'].each {|signal| trap(signal) {server.shutdown} } server.start end #start_webrick(:DocumentRoot => "g:/infoproweb/webfolder/cgi-bin/ruby",:CGIInterpreter => "g:/ruby/bin/ruby.exe") start_webrick(:DocumentRoot => "g:/infoproweb/webfolder/") start_webrick {|server| #cgi_dir = File.expand_path('~/cgi-bin/ruby') cgi_dir = "g:/infoproweb/webfolder/cgi-bin/ruby" server.mount("/cgi-bin/ruby", HTTPServlet::FileHandler, cgi_dir, {:FancyIndexing=>true}) } -- Posted via http://www.ruby-forum.com/.