From: PerfectDayToChaseTornados Date: 2007-03-23T05:20:17+09:00 Subject: Re: Webrick problem, PREMATURE END OF SCRIPT HEADERS "Kevin Layman" wrote in message news:d069c243a419b320e40fc9de0a2e6b8d@ruby-forum.com... > 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/. You probably have something else already running on that port. Either start Webrick on a different port or stop whatever is bound to that port. -- pdtct