2011-04-06 117 views
0

我使用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 

我也試着設置每頭我能與螢火蟲看到,這樣的要求是在兩種情況下是相同的,不成功。 出了什麼問題?

回答

5

看起來你似乎沒有任何後期數據與您的請求。您可能沒有正確設置捲髮傳輸。

您的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

也許他們會阻止捲曲,因爲他們認爲這是一個試圖攻擊其系統的機器人。他們將能夠根據您的請求發送的標題來檢測用戶代理。

+0

可能,但不是很可能根據粘貼日誌。 – vbence 2011-04-06 12:11:35

+0

我嘗試使用與firefox 4相同的用戶代理,但它不會更改任何內容 – greg0ire 2011-04-06 12:11:38