让我们说我的POST数据在cURL命令中看起来像这样
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对我没有帮助!谢谢。节日快乐!! :)
答案 0 :(得分: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