我正在使用libcurl将xml数据发送到服务器。我正在使用readfunction
方法发布数据。但是在发布标题后,content-length
标题将更改为-1。我从libcurl收到错误消息: -
HTTP error before end of send, stop sending
Content-Type: text/xml
Content-Length: 249
<?xml version="1.0" encoding="UTF-8"?><STBSCANMANUALINFO><FREQUENCY>305944</FREQUENCY> <SYMBOLRATE>6899</SYMBOLRATE><MODULATION> MOD_64QAM</MODULATION><STATUS> LOCKED</STATUS><QUALITY>100</QUALITY><BER>0</BER><RFLEVEL>40</RFLEVEL></STBSCANMANUALINFO>
Connection:keep-alive
Content-Length: -1
Expect: 100-continue
我没有得到我做错的地方。
答案 0 :(得分:0)
使用CURLOPT_POSTFIELDSIZE
显式设置POST
尺寸,如official sample code所示:
/* Set the expected POST size. If you want to POST large amounts of data,
consider CURLOPT_POSTFIELDSIZE_LARGE */
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, pooh.sizeleft);