Standalone webserver to serve HTTP GET requests

36 views Asked by At

I'm developing a webserver(FCGI) based on using gsoap v2.8. This webserver shall respond to the incoming HTTP GET requests but it's not working.

I got to know that gsoap provides HTTP callbacks to achieve this, In my case I'm using soap->fget callback. I went through the gsoap documentation and I'm following the same.

main function fget code

I understand that whenever there is a incoming HTTP GET requests, the soap_serve (generated by gsoap) function shall call fget callback function but I see that my function http_get is not getting hit and soap_serve is returning -1 with error message "Response-Header: \nHTTP/1.1 500 Internal Server Error\r\nServer:"

I'm not sure if anything to be corrected/added in my code to handle HTTP GET requests by my webserver.

Any quick response will really help me. Thank you in advance.

1

There are 1 answers

2
Dr. Alex RE On

The fget() callback is not invoked when FCGI or CGI is used, because the HTTP headers are stripped from the inbound message. Therefore, soap_serve() assumes this is a POST request by default. To respond to GET requests, do not call soap_serve() right away. Check the environment variable REQUEST_METHOD is GET and then produce the corresponding output. Check if the environment variable PATH_INFO or PATH_TRANSLATED and QUERY_STRING match the URL your service should respond to. Never return files located on the server that are identified by PATH_INFO or by QUERY_STRING, which is a security risk. Only return files or output that should be publicly visible.