开发者

Ruby Apache CGI Premature end of script headers

开发者 https://www.devze.com 2023-01-08 20:04 出处:网络
I\'m trying to make a simple redirect work.I\'ve gotten everything else to work just fine.For example, this works:

I'm trying to make a simple redirect work. I've gotten everything else to work just fine. For example, this works:

#!/usr/bin/env ruby

puts "Content-type: text/html"
puts
puts "<h1>blah</h1>"

But this doesn't work (this is where I get the "Premature end of script headers" error):

#!/usr/bin/env ruby

puts "Status: 302 Found"
puts "Content-type: text/html"
puts "Location: http://google.com"

All of the other suggestions I've found say it's probably something to do with the #!/usr/bin/env ruby part of the开发者_如何学JAVA script, but that doesn't make any sense to me since it works with the first example. Any suggestions?

It seems like Apache is parsing the headers I'm returning from the cgi script. Is there are way to turn that off?


You forgot the ending puts.

#!/usr/bin/env ruby

puts "Status: 302 Found"
puts "Content-type: text/html"
puts "Location: http://google.com"
puts
0

精彩评论

暂无评论...
验证码 换一张
取 消