mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-31 08:54:38 +00:00
don't send Transfer-Encoding: chunked for newer libcurl
This commit is contained in:
parent
7e513867b1
commit
1e531bee80
30
util.cpp
30
util.cpp
@ -272,23 +272,6 @@ static size_t all_data_cb(const void *ptr, size_t size, size_t nmemb,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t upload_data_cb(void *ptr, size_t size, size_t nmemb,
|
|
||||||
void *user_data)
|
|
||||||
{
|
|
||||||
struct upload_buffer *ub = (struct upload_buffer *)user_data;
|
|
||||||
unsigned int len = (unsigned int)(size * nmemb);
|
|
||||||
|
|
||||||
if (len > ub->len - ub->pos)
|
|
||||||
len = (unsigned int)(ub->len - ub->pos);
|
|
||||||
|
|
||||||
if (len) {
|
|
||||||
memcpy(ptr, (char*)ub->buf + ub->pos, len);
|
|
||||||
ub->pos += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LIBCURL_VERSION_NUM >= 0x071200
|
#if LIBCURL_VERSION_NUM >= 0x071200
|
||||||
static int seek_data_cb(void *user_data, curl_off_t offset, int origin)
|
static int seek_data_cb(void *user_data, curl_off_t offset, int origin)
|
||||||
{
|
{
|
||||||
@ -429,7 +412,6 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
|
|||||||
json_t *val, *err_val, *res_val;
|
json_t *val, *err_val, *res_val;
|
||||||
int rc;
|
int rc;
|
||||||
struct data_buffer all_data = { 0 };
|
struct data_buffer all_data = { 0 };
|
||||||
struct upload_buffer upload_data;
|
|
||||||
json_error_t err;
|
json_error_t err;
|
||||||
struct curl_slist *headers = NULL;
|
struct curl_slist *headers = NULL;
|
||||||
char *httpdata;
|
char *httpdata;
|
||||||
@ -455,10 +437,12 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
|
|||||||
curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1);
|
curl_easy_setopt(curl, CURLOPT_TCP_NODELAY, 1);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, all_data_cb);
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, all_data_cb);
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &all_data);
|
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 LIBCURL_VERSION_NUM >= 0x071200
|
#if LIBCURL_VERSION_NUM >= 0x071200
|
||||||
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, &seek_data_cb);
|
curl_easy_setopt(curl, CURLOPT_SEEKFUNCTION, &seek_data_cb);
|
||||||
|
struct upload_buffer upload_data;
|
||||||
|
upload_data.buf = rpc_req;
|
||||||
|
upload_data.len = strlen(rpc_req);
|
||||||
|
upload_data.pos = 0;
|
||||||
curl_easy_setopt(curl, CURLOPT_SEEKDATA, &upload_data);
|
curl_easy_setopt(curl, CURLOPT_SEEKDATA, &upload_data);
|
||||||
#endif
|
#endif
|
||||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_err_str);
|
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, curl_err_str);
|
||||||
@ -479,14 +463,12 @@ static json_t *json_rpc_call(CURL *curl, const char *url,
|
|||||||
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_keepalive_cb);
|
curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_keepalive_cb);
|
||||||
#endif
|
#endif
|
||||||
curl_easy_setopt(curl, CURLOPT_POST, 1);
|
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)
|
if (opt_protocol)
|
||||||
applog(LOG_DEBUG, "JSON protocol request:\n%s", rpc_req);
|
applog(LOG_DEBUG, "JSON protocol request:\n%s", rpc_req);
|
||||||
|
|
||||||
upload_data.buf = rpc_req;
|
|
||||||
upload_data.len = strlen(rpc_req);
|
|
||||||
upload_data.pos = 0;
|
|
||||||
sprintf(len_hdr, "Content-Length: %lu", (unsigned long) upload_data.len);
|
|
||||||
sprintf(hashrate_hdr, "X-Mining-Hashrate: %llu", (unsigned long long) global_hashrate);
|
sprintf(hashrate_hdr, "X-Mining-Hashrate: %llu", (unsigned long long) global_hashrate);
|
||||||
|
|
||||||
headers = curl_slist_append(headers, "Content-Type: application/json");
|
headers = curl_slist_append(headers, "Content-Type: application/json");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user