splintor
splintor

Reputation: 10154

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

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

Upvotes: 1

Views: 2827

Answers (1)

Williham Totland
Williham Totland

Reputation: 29009

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

Upvotes: 4

Related Questions