Skip to content

Commit 1e531be

Browse files
committed
don't send Transfer-Encoding: chunked for newer libcurl
1 parent 7e51386 commit 1e531be

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

Diff for: util.cpp

+6-24
Original file line numberDiff line numberDiff line change
@@ -272,23 +272,6 @@ static size_t all_data_cb(const void *ptr, size_t size, size_t nmemb,
272272
return len;
273273
}
274274

275-
static size_t upload_data_cb(void *ptr, size_t size, size_t nmemb,
276-
void *user_data)
277-
{
278-
struct upload_buffer *ub = (struct upload_buffer *)user_data;
279-
unsigned int len = (unsigned int)(size * nmemb);
280-
281-
if (len > ub->len - ub->pos)
282-
len = (unsigned int)(ub->len - ub->pos);
283-
284-
if (len) {
285-
memcpy(ptr, (char*)ub->buf + ub->pos, len);
286-
ub->pos += len;
287-
}
288-
289-
return len;
290-
}
291-
292275
#if LIBCURL_VERSION_NUM >= 0x071200
293276
static int seek_data_cb(void *user_data, curl_off_t offset, int origin)
294277
{
@@ -429,7 +412,6 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
429412
json_t *val, *err_val, *res_val;
430413
int rc;
431414
struct data_buffer all_data = { 0 };
432-
struct upload_buffer upload_data;
433415
json_error_t err;
434416
struct curl_slist *headers = NULL;
435417
char *httpdata;
@@ -455,10 +437,12 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
455437
curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1);
456438
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, all_data_cb);
457439
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &all_data);
458-
curl_easy_setopt(curl, CURLOPT_READFUNCTION, upload_data_cb);
459-
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_data);
460440
#if LIBCURL_VERSION_NUM >= 0x071200
461441
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, &seek_data_cb);
442+
struct upload_buffer upload_data;
443+
upload_data.buf = rpc_req;
444+
upload_data.len = strlen(rpc_req);
445+
upload_data.pos = 0;
462446
curl_easy_setopt(curl, CURLOPT_SEEKDATA, &upload_data);
463447
#endif
464448
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_err_str);
@@ -479,14 +463,12 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
479463
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_keepalive_cb);
480464
#endif
481465
curl_easy_setopt(curl, CURLOPT_POST, 1);
466+
curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen (rpc_req));
467+
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, rpc_req);
482468

483469
if (opt_protocol)
484470
applog(LOG_DEBUG, "JSON protocol request:\n%s", rpc_req);
485471

486-
upload_data.buf = rpc_req;
487-
upload_data.len = strlen(rpc_req);
488-
upload_data.pos = 0;
489-
sprintf(len_hdr, "Content-Length: %lu", (unsigned long) upload_data.len);
490472
sprintf(hashrate_hdr, "X-Mining-Hashrate: %llu", (unsigned long long) global_hashrate);
491473

492474
headers = curl_slist_append(headers, "Content-Type: application/json");

0 commit comments

Comments
 (0)