Ruby Apache CGI 脚本标头过早结束

发布于 2024-09-11 00:29:13 字数 488 浏览 1 评论 0原文

我正在尝试做一个简单的重定向工作。我已经让其他一切都工作得很好。例如,这有效:

#!/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终陌 2024-09-18 00:29:13

您忘记了结尾的看跌

#!/usr/bin/env ruby

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

You forgot the ending puts.

#!/usr/bin/env ruby

puts "Status: 302 Found"
puts "Content-type: text/html"
puts "Location: http://google.com"
puts
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文