@@ -272,23 +272,6 @@ static size_t all_data_cb(const void *ptr, size_t size, size_t nmemb,
272
272
return len;
273
273
}
274
274
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
-
292
275
#if LIBCURL_VERSION_NUM >= 0x071200
293
276
static int seek_data_cb (void *user_data, curl_off_t offset, int origin)
294
277
{
@@ -429,7 +412,6 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
429
412
json_t *val, *err_val, *res_val;
430
413
int rc;
431
414
struct data_buffer all_data = { 0 };
432
- struct upload_buffer upload_data;
433
415
json_error_t err;
434
416
struct curl_slist *headers = NULL ;
435
417
char *httpdata;
@@ -455,10 +437,12 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
455
437
curl_easy_setopt (curl, CURLOPT_TCP_NODELAY, 1 );
456
438
curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, all_data_cb);
457
439
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);
460
440
#if LIBCURL_VERSION_NUM >= 0x071200
461
441
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 ;
462
446
curl_easy_setopt (curl, CURLOPT_SEEKDATA, &upload_data);
463
447
#endif
464
448
curl_easy_setopt (curl, CURLOPT_ERRORBUFFER, curl_err_str);
@@ -479,14 +463,12 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
479
463
curl_easy_setopt (curl, CURLOPT_SOCKOPTFUNCTION, sockopt_keepalive_cb);
480
464
#endif
481
465
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);
482
468
483
469
if (opt_protocol)
484
470
applog (LOG_DEBUG, " JSON protocol request:\n %s" , rpc_req);
485
471
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 );
490
472
sprintf (hashrate_hdr, " X-Mining-Hashrate: %llu" , (unsigned long long ) global_hashrate);
491
473
492
474
headers = curl_slist_append (headers, " Content-Type: application/json" );
0 commit comments