【问题标题】:Gateway timeout caused by simple CGI script简单 CGI 脚本导致网关超时
【发布时间】:2014-11-30 06:11:49
【问题描述】:

我有一个简单的 CGI 脚本:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    printf("<form name='mainform' method='POST' action='http://localhost/cgi-bin/test.cgi>'>";
    printf("<h2>Hello, world!</h2>");
     printf("<button type='submit' name='submitbtn'>Submit</button>");
     printf("</form>");
    return 0;
}

当我从网络浏览器的 URL 栏中运行它时,一切正常。但是当我按“提交”时,状态栏“等待本地主机”出现,然后出现“504 网关超时”错误

【问题讨论】:

    标签: apache cgi


    【解决方案1】:

    我见过的每个 hello world CGI 都会发出一个 Content-Type,然后是 CRLF CRLF。你不能只吐出 HTML。

    更新:您还需要在提交操作时将标准输入(POST 正文)读取到 EOF。

    【讨论】:

    • 感谢,召集人。我添加了 Content-Type,然后是 CRLF CRLF。但同样,当我从浏览器 URL 栏中运行脚本时,它可以工作。但是当我按下提交按钮时,出现同样的“网关超时”错误
    • 尝试阅读 stdin 以用尽处理发生的帖子。
    猜你喜欢
    • 2020-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-16
    • 1970-01-01
    • 2014-10-14
    • 1970-01-01
    相关资源
    最近更新 更多