CGI应用程序中某些页面上的HTTP 502错误 [英] HTTP 502 error on some pages within a CGI application

查看:420
本文介绍了CGI应用程序中某些页面上的HTTP 502错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all



我一直在使用C ++在linux下使用现有的CGI应用程序。在某些页面上它给我带来错误的问题



502 Bad Gateway

CGI不符合CGI 1.1



在此之前,它在同一页面上写道cgi_header:找不到LFLF!



这个程序有点奇怪正确启动,但当我转到特定页面时,我收到此错误。我尝试使用fstream对象来记录崩溃的确切位置,但我发现如果我只写这个



 ofstream ff(  test.txt,ofstream :: app); 

// 代码
// 显示
// 页面

// 最后一行
ff.close();





甚至不写任何内容只是声明并关闭它会使页面运行正常!



系统使用相同的代码,但在某些页面上使用不同的参数,页面的内容来自sqlite 3数据库,数据库数据正确,可以查看,有其他页面在相同的代码上完美地工作,但有特定的页面卡在这个错误上:\(换句话说,其他页面上的相同代码工作!)



我已经检查了有关代码,数据库或HTML的所有内容。我也在线搜索,所有结果都说明了同样的事情,我应该确保在Content-type:text / HTML之后打印一个空行(cout<<Content-type:text / HTML \ nn n;)甚至在我的代码中这是正确的。



PS:当我通过我正在使用的嵌入式Linux设备运行应用程序时会出现这种情况,如果我通过PC上的localhost运行它一切正常。



任何帮助表示赞赏,谢谢!

解决方案

< blockquote>请参阅


Hello all

I have been working with an existing CGI application under linux with C++. The problem that on some pages it gives me the error

502 Bad Gateway
The CGI was not CGI 1.1 compliant

Before that it wrote on the same page "cgi_header: unable to find LFLF"!

What's more weird is the program starts correctly but when I go to specific pages I get this error. I tried to use an fstream object to log where the exact point of the crash but I found out that if I only write this

ofstream ff("test.txt", ofstream::app);

// The Code
// That displays
// The page

// Last line
ff.close();



and even not writing anything to the stream just declare and close it will make the page run correctly!

The system uses the same code but with different parameters on some pages, the page's contents come form sqlite 3 database and the database data is correct and can be viewed , there are other pages that works perfectly on the same code but there are specific pages that stuck on this error :\ (in other words, same code on other pages work!)

I've checked everything regarding the code, database or HTML. I also searched online and all results tells the same thing, I should make sure to print an empty line after "Content-type:text/HTML" (cout << "Content-type:text/HTML\n\n";) and even this is correct in my code.

PS: This situation happens when I run the application via an embedded linux device I'm using, If I run it through the localhost on my PC everything works.

Any help is appreciated, Thanks!

解决方案

Refer to this


这篇关于CGI应用程序中某些页面上的HTTP 502错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆