使用curl和https网址的400个错误请求

时间:2011-04-06 12:04:20

标签: php curl symfony1

我正在使用curl(通过symfony的插件sfWebBrowser和sfCurlAdapter),我正在尝试在https网址上执行一个非常简单的POST请求。

使用普通浏览器执行此操作可获得200 OK,而curl会收到“400 Bad Request”错误。

我在curl上使用了verbose选项,这就是我得到的:

* 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

我还尝试设置我可以用firebug看到的每个标头,以便在两种情况下请求都相同,但没有成功。 出了什么问题?

2 个答案:

答案 0 :(得分:5)

您的请求似乎没有后期数据。您可能没有正确设置卷曲传输。

您的POST应该至少有一个Content-Length标题。

答案 1 :(得分:0)

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