cgi bug? with iis 5 and nph

C

Chris Morris

The 1.8 cgi module has the following bit:

if options.delete("nph") or /IIS/n.match(env_table['SERVER_SOFTWARE'])
buf += (env_table["SERVER_PROTOCOL"] or "HTTP/1.0") + " " +
(HTTP_STATUS[options["status"]] or options["status"] or
"200 OK") +
EOL +
"Date: " + CGI::rfc1123_date(Time.now) + EOL

... which forces an HTTP status line in the response if IIS is the web
server. But this is wrong (at least with IIS 5.0).

This script (sample.cgi.rb):

require 'cgi'

cgi = CGI.new("html3")
cgi.out {
cgi.html {
cgi.body { 'hey'
}
}
}

On IIS 5 generates this header:

HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Wed, 03 Sep 2003 17:07:57 GMT
Connection: close
HTTP/1.1 200 OK
Date: Wed, 03 Sep 2003 17:07:57 GMT
Server: Microsoft-IIS/5.0
Connection: close
Content-Type: text/html
Content-Length: 84

If the file is renamed to 'nph-sample.cgi.rb' this flags IIS that it's a
non parsed header script and then it works fine.

note: IE 6 and Mozilla 1.4 both are forgiving of the incorrect http
response header, but Ruby's net/http is not:

c:/ruby/lib/ruby/1.8/net/http.rb:1561:in `each_response_header':
wrong header li
ne format (Net::HTTPBadResponse)

Calling

ENV['SERVER_SOFTWARE'] = ''

... before calling cgi.out seems to be a suitable workaround for now.

Can cgi.rb be changed to look for whatever version of IIS required this
workaround, or changed to not do nph if SERVER_SOFTWARE =~ /IIS\/5.0/?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top