Http post 发生404错误时gsoap更改响应内容类型
我正在使用gsoap httppost插件来实现接受post请求的服务器 如果出现错误,我将返回404错误,但内容类型始终为Http post 发生404错误时gsoap更改响应内容类型,http-post,gsoap,Http Post,Gsoap,我正在使用gsoap httppost插件来实现接受post请求的服务器 如果出现错误,我将返回404错误,但内容类型始终为text/xml,但我要求内容类型为text/html 下面是代码片段 int wildcard_handler(struct soap* soap) { stringstream ss; ss << "In wild card handler content_type" << soap->http_content; L
text/xml
,但我要求内容类型为text/html
下面是代码片段
int wildcard_handler(struct soap* soap)
{
stringstream ss;
ss << "In wild card handler content_type" << soap->http_content;
LOGDEBUG(ss.str());
soap->http_content = "text/html";
soap_send_empty_response(soap, 404);
return SOAP_OK;
}
int通配符\u处理程序(结构soap*soap)
{
细流ss;
ss http_content=“text/html”;
soap\u发送\u空\u响应(soap,404);
返回SOAP_OK;
}
但在浏览器上,我收到text/xml&错误404。来自,以便返回text/html
答案,您应该使用:
int wildcard_handler(struct soap* soap)
{
soap_response(soap, SOAP_HTML);
soap_send(soap, "<HTML>...</HTML>");
soap_end_send(soap);
soap_closesock(soap);
return SOAP_OK;
}
int通配符\u处理程序(结构soap*soap)
{
soap_响应(soap、soap_HTML);
soap_send(soap,“…”);
soap\u end\u send(soap);
肥皂盒(肥皂);
返回SOAP_OK;
}
这将允许您发送HTML答案,但不会发送错误404
为了发送404和文本/html
内容是可能的,但它更复杂,因为它需要覆盖soap->Frespose处理程序来传播http错误代码和soap\u html标志