如何查看完整請求標頭,包括髮布數據,在php中使用libcurl?查看帶有POST數據的cURL請求標頭
我試圖模擬一個頁面,從瀏覽器中完成,並在Live HTTP頭看時的職位是這樣的:
https://###.com
POST /###/### HTTP/1.1
Host: ###.###.com
...snipped normal looking headers...
Content-Type: multipart/form-data; boundary=---------------------------28001808731060
Content-Length: 697
-----------------------------28001808731060
Content-Disposition: form-data; name="file_data"; filename="stats.csv"
Content-Type: text/csv
id,stats_id,scope_id,stat_begin,stat_end,value
61281,1,4,2011-01-01 00:00:00,2011-12-31 23:59:59,0
-----------------------------28001808731060
Content-Disposition: form-data; name="-save"
Submit
-----------------------------28001808731060--
所以我們很好地看到我上傳文件,它的內容,一切都在那裏。但是,所有我在獲取數據出捲曲的嘗試,當我試圖讓從PHP同一職位(使用CURLOPT_VERBOSE
,或CURLINFO_HEADER_OUT
)表明,缺乏後的數據,像這樣請求頭:基於內容
POST /###/### HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
Host: ###.###.com
...snipped normal-looking headers...
Content-Length: 697
Content-Type: multipart/form-data; boundary=----------------------------e90de36c15f5
- 在這裏,看起來事情進展順利,但它確實有助於我的調試工作能夠看到完整的請求。我也覺得這很困難,我應該能夠看到整個事情;我知道我必須失去一些東西。
---編輯---
什麼我要找的是this等價的:
curl --trace-ascii debugdump.txt http://www.example.com/
這似乎是可用libcurl中的選項CURLOPT_DEBUGFUNCTION,但ISN」在php中執行t。噓。
這是非常有用的,謝謝。在我看來,仍然有可能從cURL獲取有關請求的「主要HTTP主體」的信息。 – Chris