How to return a 500 HTTP status from a C++ CGI program

最后都变了- 提交于 2019-12-11 09:27:37

问题


I have a small "SOAP CGI gatewqay" C++ program that reads an HTTP SOAP request from cin, get the request info from it and sends it to the legacy server. Then it taks the response, format it as a SOAP response and write it to cout.

In case of an error, it writes a <SOAP-ENV:Fault> reponse to cout. However, the SOAP standard says that in case of error, the returned HTTP status should be 500 "Internal Server Error". This SOAP CGI gateway should run on any web server that supports CGI. What is the proper way to set the HTTP status returned by the web server when the CGI returns?

Thanks, splintor


回答1:


You write a "Status: 500 Internal Server Error" to the headers. This has to be written before any content is written of course.



来源:https://stackoverflow.com/questions/1318507/how-to-return-a-500-http-status-from-a-c-cgi-program

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!