Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Http post 发生404错误时gsoap更改响应内容类型_Http Post_Gsoap - Fatal编程技术网

Http post 发生404错误时gsoap更改响应内容类型

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

我正在使用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;
    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标志