2015-12-24 66 views
0

比方說,我的POST數據看起來像這樣在捲曲命令有沒有辦法用cURL寫一個POST調用的整個請求體?

cURL -v -b cookies.txt -X POST -H "Content-Type:application/json" http://localhost:7501/rest/model/customer/getCustomerData -d {"_dynSessConf":"-1234567891235698","custId":"1109"} -o "customerData.txt" 

customerData.txt正確的輸出記錄。我的問題 -

有沒有辦法記錄請求主體呢? (從會話確認號碼開始的json部分)?

我真的很感謝任何幫助,因爲cURL man page不能幫助我!謝謝。節日快樂!! :)

回答

1

看來the closest you can get is using --trace-ascii option,例如:

cURL --trace-ascii - -v -b cookies.txt ... # rest of your command... 

輸出看起來像:

=> Send header, 225 bytes (0xe1) 
0000: POST /rest/model/customer/getCustomerData HTTP/1.1 
0034: Host: localhost 
0046: User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; 
0086: Trident/6.0) 
0094: Accept: */* 
00a1: Referer: 
00ac: Content-Type:application/json 
00cb: Content-Length: 52 
00df: 
=> Send data, 52 bytes (0x34) 
0000: {"_dynSessConf":"-1234567891235698","custId":"1109"} 
== Info: upload completely sent off: 52 out of 52 bytes 
<= Recv SSL data, 5 bytes (0x5) 

...然後很多很多行。您可以通過指定文件名而不是-作爲參數將其保存在文件中,例如--trace-ascii trace.log

相關問題