【问题标题】:Content Length header is changing after posting xml (HTTP POST using libcurl)发布 xml 后,内容长度标头正在更改(使用 libcurl 的 HTTP POST)
【发布时间】:2014-01-09 09:37:49
【问题描述】:

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

我不知道我在哪里做错了。

【问题讨论】:

    标签: xml curl http-headers http-post libcurl


    【解决方案1】:

    使用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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-23
      • 1970-01-01
      • 2012-12-02
      • 2012-04-01
      • 2015-12-30
      • 2019-06-30
      • 2017-02-07
      • 2011-05-24
      相关资源
      最近更新 更多