我执行LibCurl语句时遇到了麻烦,至少看起来如此。我尝试将15MB文件发送到脚本正在侦听的端口,该端口将处理该文件并返回响应。但是,在我得到任何响应之前,程序崩溃了(只有1个15MB的pptx文件,比其他文件的'普通'大)
但是,有没有人在LibCurl日志中看到一些奇怪的东西:
* timeout on name lookup is not supported
* Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 13621 (#0)
> PUT //File processing argument//
Host: localhost:13621
Accept: application/json
Accept: application/json
Content-Length: 15828910
* We are completely uploaded and fine
< HTTP/1.1 200 OK
< Content-Type: application/json
< Date: Tue, 14 Mar 2017 20:37:41 GMT
< Transfer-Encoding: chunked
< Server: Jetty(8.y.z-SNAPSHOT)
<
* Curl_http_done: called premature == 0
* Connection #0 to host localhost left intact
Process returned -1073741571 (0xC00000FD) execution time : 12.682 s
我使用的代码:
curl = curl_easy_init();
if (curl) {
CurlResponse = "";
host = "localhost:13621";
LibcurlHeaders = curl_slist_append(LibcurlHeaders, "Expect:");
LibcurlHeaders = curl_slist_append(LibcurlHeaders, "Accept: application/json");
curl_easy_setopt(curl, CURLOPT_URL, (host).c_str());
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
curl_easy_setopt(curl, CURLOPT_READDATA, fd);
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, LibcurlHeaders);
curl_easy_setopt(curl, CURLOPT_VERBOSE, CurlVerbose);
curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, LibcurlResponse);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &CurlResponse);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
curl_global_cleanup();
感谢您的回复