【发布时间】:2012-10-18 14:41:48
【问题描述】:
这是数据包的外观
HTTP/1.1 200 OK
Content-Encoding: gzip
Vary: Accept-Encoding
Date: Thu, 18 Oct 2012 13:52:49 GMT
Server: LiteSpeed
Connection: close
X-Powered-By: PHP/5.3.10
Content-Type: text/html
Content-Length: 35
和
HTTP/1.1 200 OK
Content-Length: 35
Content-Type: text/html
Content-Encoding: gzip
Vary: Accept-Encoding
Server: Microsoft-HTTPAPI/2.0
Date: Thu, 18 Oct 2012 14:17:13 GMT
Connection: close
两者的 GZIP 输出是相同的,但使用 PHP 生成的顶部的输出有效,而生成的 HttpListenerResponse 生成的底部不使用 POST 请求,即使您可以在浏览器中查看两者。我也不叫跨域/端口。
如何使第二个请求生效?
【问题讨论】:
-
如何使第二个工作明显? HttpListenerResponse 似乎不适用于 POST。
-
你是如何执行 POST 请求的?当你说
the second it doesn't work时,你能定义一下it doesn't work是什么意思吗?也许您收到错误消息或其他什么? -
@DarinDimitrov
requestArray[id].open(method,url,true); requestArray[id].setRequestHeader("Content-type","application/x-www-form-urlencoded");是我发送请求的部分,if (requestArray[id].readyState==4 && requestArray[id].status==200) { return true; } else { return false; }是始终为我的 HttpListener 返回 false 的部分,无论我是否发送消息(即使我可以打开它在浏览器中)对于 php 脚本,一切正常并返回 true。
标签: c# php httplistener