PHP CURL将\0(NUL字符)添加到方法/错误501 RFC 2068中未定义方法POST

PHP CURL将\0(NUL字符)添加到方法/错误501 RFC 2068中未定义方法POST,php,post,curl,http-post,fiddler,Php,Post,Curl,Http Post,Fiddler,我有这个curl脚本,它是用Fiddler导出的 那是我的尝试 这就是$body的反应 这就是调试信息 在帖子前面是一个NUL符号。 也许这就是问题所在 是的,它看起来确实有一个空间,这就是它失败的原因。设置CURLOPT_POST是否有帮助?您可能还希望对POST字段进行编码:您是每次都看到它,还是仅每秒看到一次?如果是每秒一次,这意味着这是CURL中的连接重用错误,或者内容长度错误。你能从Fiddler中捕获cURL的请求并将其存储在Fiddler SAZ文件中吗?@EricLaw xD我一

我有这个curl脚本,它是用Fiddler导出的

那是我的尝试

这就是$body的反应

这就是调试信息

在帖子前面是一个NUL符号。 也许这就是问题所在


是的,它看起来确实有一个空间,这就是它失败的原因。设置CURLOPT_POST是否有帮助?您可能还希望对POST字段进行编码:您是每次都看到它,还是仅每秒看到一次?如果是每秒一次,这意味着这是CURL中的连接重用错误,或者内容长度错误。你能从Fiddler中捕获cURL的请求并将其存储在Fiddler SAZ文件中吗?@EricLaw xD我一分钟前就试过了。有趣的是:如果我使用带有fiddler的反向代理,那么PHP脚本CURL就可以工作了!但是如果我替换了ip地址,它就不工作了!?该死的***--
curl
-k
-i
--raw
-o 0.dat
-X POST
"https://192.168.178.103/ws/ResourceInteractionService"
-H "Content-Language: en-US"
-H "Content-Type: text/xml"
-H "SOAPAction: setResourceValues"
-H "Cache-Control: no-cache"
-H "Pragma: no-cache"
-H "User-Agent: Java/1.7.0_25"
-H "Host: 192.168.178.103"
-H "Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"
-H "Connection: keep-alive"
-H "Cookie: JSESSIONID=-1407060770673-59-927; s_pers=%%20s_fid%%3D3B17498CEA8BA6C4-2186ABA57F7ECAEB%%7C1466279984040%%3B%%20s_vs%%3D1%%7C1403123384042%%3B%%20s_nr%%3D1403121584045-Repeat%%7C1434657584045%%3B;JSESSIONID=-1407060770673-59-927"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://192.168.178.103/ws/ResourceInteractionService');
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'SOAPAction: setResourceValues',
    'Cookie: JSESSIONID=-1407060770673-59-927; s_pers=%%20s_fid%%3D3B17498CEA8BA6C4-2186ABA57F7ECAEB%%7C1466279984040%%3B%%20s_vs%%3D1%%7C1403123384042%%3B%%20s_nr%%3D1403121584045-Repeat%%7C1434657584045%%3B;JSESSIONID=-1407060770673-59-927',
    'Content-Type: text/xml',
    'Content-Language: en-US'
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Java/1.7.0_25');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
curl_setopt($ch, CURLOPT_POSTFIELDS, '<?xml version=\'1.0\' encoding=\'UTF-8\'?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body>
<ns1:setResourceValues1 xmlns:ns1="utcs">
<ns1:arrayItem xsi:type="ns1:WSResourceValueEnvelope">
<ns1:value xmlns:ns2="utcs.values"  xsi:type="ns2:WSBooleanValue">
<ns2:value xsi:type="xsd:boolean">true</ns2:value>
</ns1:value>

<ns1:typeString xsi:type="xsd:string"></ns1:typeString>

<ns1:resourceID xsi:type="xsd:int">25435</ns1:resourceID>

<ns1:isValueRuntime xsi:type="xsd:boolean">true</ns1:isValueRuntime>
</ns1:arrayItem>
</ns1:setResourceValues1>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
list($header, $body) = explode("\r\n\r\n", curl_exec($ch), 2);
var_dump($header, $body);
curl_close($ch);
HTTP/1.1 501 Method POST is not defined in RFC 2068 and is not supported by the Servlet API 
content-type: text/html
date: Sun, 03-Aug-2014 11:32:26 GMT
keep-alive: timeout=900, max=1000
connection: Keep-Alive
content-length: 366
server: Rogatkin's JWS based on Acme.Serve/$Revision: 1.39 $
mime-version: 1.0
set-cookie: JSESSIONID=-1407060770673-59-927
<HTML><HEAD><TITLE>501 Method POST is not defined in RFC 2068 and is not supported by the Servlet API </TITLE></HEAD><BODY BGCOLOR="#F1D0F2"><H2>501 Method POST is not defined in RFC 2068 and is not supported by the Servlet API </H2><HR><ADDRESS><A HREF="http://tjws.sourceforge.net">Rogatkin's JWS based on Acme.Serve $Revision: 1.39 $</A></ADDRESS></BODY></HTML>
* About to connect() to 192.168.178.103 port 443 (#0)
*   Trying 192.168.178.103...
* connected
* Connected to 192.168.178.103 (192.168.178.103) port 443 (#0)
* SSL connection using AES256-SHA
* Server certificate:
*    subject: CN=IHC; O=Schneider Electric; C=FR
*    start date: 2014-01-07 05:21:31 GMT
*    expire date: 2034-01-02 05:21:31 GMT
*    issuer: CN=IHC; O=Schneider Electric; C=FR
*    SSL certificate verify result: self signed certificate (18), continuing anyway.
> POST /ws/ResourceInteractionService HTTP/1.1
User-Agent: Java/1.7.0_25
Host: 192.168.178.103
Accept: */*
SOAPAction: setResourceValues
Cookie: JSESSIONID=-1407060770673-59-927; s_pers=%%20s_fid%%3D3B17498CEA8BA6C4- 2186ABA57F7ECAEB%%7C1466279984040%%3B%%20s_vs%%3D1%%7C1403123384042%%3B%%20s_nr%%3D1403121584045-Repeat%%7C1434657584045%%3B;JSESSIONID=-1407060770673-59-927
Content-Type: text/xml
Content-Language: en-US
Content-Length: 746

* upload completely sent off: 746 out of 746 bytes
< HTTP/1.1 501 Method