Browse Source

don't send Transfer-Encoding: chunked for newer libcurl

master
orignal 2 years ago
parent
commit
30588be6db
  1. 10
      util.c

10
util.c

@ -85,7 +85,6 @@ json_t *json_rpc_call(const char *url, const char *userpass, const char *rpc_req @@ -85,7 +85,6 @@ json_t *json_rpc_call(const char *url, const char *userpass, const char *rpc_req
json_t *val;
int rc;
struct data_buffer all_data = { };
struct upload_buffer upload_data;
json_error_t err = { };
struct curl_slist *headers = NULL;
char len_hdr[64];
@ -102,22 +101,17 @@ json_t *json_rpc_call(const char *url, const char *userpass, const char *rpc_req @@ -102,22 +101,17 @@ json_t *json_rpc_call(const char *url, const char *userpass, const char *rpc_req
curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, all_data_cb);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &all_data);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, upload_data_cb);
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_data);
if (userpass) {
curl_easy_setopt(curl, CURLOPT_USERPWD, userpass);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}
curl_easy_setopt(curl, CURLOPT_POST, 1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen (rpc_req));
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, rpc_req);
if (opt_protocol)
printf("JSON protocol request:\n%s\n", rpc_req);
upload_data.buf = rpc_req;
upload_data.len = strlen(rpc_req);
sprintf(len_hdr, "Content-Length: %lu",
(unsigned long) upload_data.len);
headers = curl_slist_append(headers,
"Content-type: application/json");
headers = curl_slist_append(headers, len_hdr);

Loading…
Cancel
Save