如何从C ++ CGI程序返回500 HTTP状态 [英] How to return a 500 HTTP status from a C++ CGI program

查看:60
本文介绍了如何从C ++ CGI程序返回500 HTTP状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小的 SOAP CGI gatewqay C ++程序,它从 cin 读取HTTP SOAP请求,从中获取请求信息,并将其发送到旧服务器。然后,它会接收响应,将其格式化为SOAP响应,然后将其写入 cout

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.

如果发生错误,它会写一个< SOAP-ENV:Fault> 响应 cout 。但是, SOAP标准表示在发生错误的情况下,返回的HTTP状态应为500内部服务器错误。该SOAP CGI网关应在任何支持CGI的Web服务器上运行。设置CGI返回时由Web服务器返回的HTTP状态的正确方法是什么?

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?

感谢
splintor

Thanks, splintor

推荐答案

您在标头中写入状态:500内部服务器错误。当然,这必须在编写任何内容之前进行。

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

这篇关于如何从C ++ CGI程序返回500 HTTP状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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