400 curl和https url的错误请求

问题描述:

我使用curl(通过symfony的插件sfWebBrowser以及sfCurlAdapter),我试图在https url上做一个非常简单的POST请求。400 curl和https url的错误请求

使用普通浏览器进行此操作会产生200 OK,而curl会收到“400错误请求”错误。

我用卷曲的详细选项,这里是我得到了什么:

* About to connect() to preprod-ppps.paybox.com port 443 (#0) 
* Trying 195.101.99.73... % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
    0  0 0  0 0  0  0  0 --:--:-- --:--:-- --:--:--  0* connected 
* Connected to preprod-ppps.paybox.com (195.101.99.73) port 443 (#0) 
* successfully set certificate verify locations: 
* CAfile: none 
    CApath: /etc/ssl/certs 
* SSL connection using DHE-RSA-AES256-SHA 
* Server certificate: 
*  subject: C=FR; postalCode=78280; ST=Yvelines; L=GUYANCOURT; street=11A rue Jacques Cartier; O=PAYBOX SERVICES; OU=0002 431408608; OU=X509 Omnidomaine TBS; CN=*.paybox.com 
*  start date: 2009-08-17 00:00:00 GMT 
*  expire date: 2011-10-03 23:59:59 GMT 
*  subjectAltName: preprod-ppps.paybox.com matched 
*  issuer: C=GB; ST=Greater Manchester; L=Salford; O=Comodo CA Limited; CN=AAA Certificate Services 
*  SSL certificate verify ok. 
> POST /PPPS.php HTTP/1.1 
Host: preprod-ppps.paybox.com 
Accept: */* 
Accept-Encoding: gzip,deflate 

< HTTP/1.1 400 Bad Request 
< Date: Wed, 06 Apr 2011 11:56:35 GMT 
< Server: HttpServer 
< Content-Length: 226 
< Connection: close 
< Content-Type: text/html; charset=iso-8859-1 
< 
100 226 100 226 0  0 793  0 --:--:-- --:--:-- --:--:-- 1013* Closing connection #0 

我也试着设置每头我能与萤火虫看到,这样的要求是在两种情况下是相同的,不成功。 出了什么问题?

看起来你似乎没有任何后期数据与您的请求。您可能没有正确设置卷发传输。

您的POST应至少包含一个Content-Length标题。

+0

在帖子中添加数据似乎没有任何改变,但是向帖子添加Content-Length标头确实会导致不同的结果:请求挂起,我要在这个方向搜索 – greg0ire 2011-04-06 12:20:37

+0

@ greg0ire它挂起,因为它等待postdta本身。您必须发送您以前在Content-Length中发送的那么多字节。 - 如果添加postdata,cURL应自动设置“Content-Length”。 – vbence 2011-04-06 12:23:19

+0

我有一些自定义代码未能添加这个帖子数据。非常感谢你! – greg0ire 2011-04-06 12:25:54

也许他们会阻止卷曲,因为他们认为这是一个试图攻击其系统的机器人。他们将能够根据您的请求发送的标题来检测用户代理。

+0

可能,但不是很可能根据粘贴日志。 – vbence 2011-04-06 12:11:35

+0

我尝试使用与firefox 4相同的用户代理,但它不会更改任何内容 – greg0ire 2011-04-06 12:11:38