Ruby Apache CGI 脚本标头过早结束
我正在尝试做一个简单的重定向工作。我已经让其他一切都工作得很好。例如,这有效:
#!/usr/bin/env ruby
puts "Content-type: text/html"
puts
puts "<h1>blah</h1>"
但这不起作用(这是我收到“脚本头过早结束”错误的地方):
#!/usr/bin/env ruby
puts "Status: 302 Found"
puts "Content-type: text/html"
puts "Location: http://google.com"
我发现的所有其他建议都说这可能与 # 有关!/usr/bin/env ruby
脚本的一部分,但这对我来说没有任何意义,因为它适用于第一个示例。有什么建议吗?
看起来 Apache 正在解析我从 cgi 脚本返回的标头。有办法把它关掉吗?
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 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您忘记了结尾的
看跌
。You forgot the ending
puts
.