【问题标题】:HttpListenerReponse and PHP POST requestsHttpListenerReponse 和 PHP POST 请求
【发布时间】: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


【解决方案1】:

添加了一些标题删除了一些标题一切都开始工作了!您需要允许访问控制来源,否则它将仅适用于 IE。

【讨论】:

    猜你喜欢
    • 2016-11-22
    • 2021-03-11
    • 1970-01-01
    • 2015-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-19
    相关资源
    最近更新 更多