mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-13 22:40:01 -04:00
fix handling of empty responses
This commit is contained in:
parent
33ac41ae33
commit
5fedc4b1ca
1 changed files with 4 additions and 1 deletions
|
@ -24,7 +24,6 @@ struct curl_blob cacert_blob;
|
||||||
|
|
||||||
size_t write_function(void *data, size_t size, size_t nmemb, struct RequestInfo *request_info) {
|
size_t write_function(void *data, size_t size, size_t nmemb, struct RequestInfo *request_info) {
|
||||||
if (!request_info->headers_received) {
|
if (!request_info->headers_received) {
|
||||||
request_info->headers_received = 1;
|
|
||||||
forward_headers(request_info);
|
forward_headers(request_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,6 +155,7 @@ CURL* start_request(const char* url, const char* json_params, DataCallback data_
|
||||||
}
|
}
|
||||||
|
|
||||||
void forward_headers(struct RequestInfo *request_info) {
|
void forward_headers(struct RequestInfo *request_info) {
|
||||||
|
request_info->headers_received = 1;
|
||||||
CURL *http_handle = request_info->http_handle;
|
CURL *http_handle = request_info->http_handle;
|
||||||
|
|
||||||
//create new json object with response info
|
//create new json object with response info
|
||||||
|
@ -201,6 +201,9 @@ void finish_request(CURLMsg *curl_msg) {
|
||||||
struct RequestInfo *request_info;
|
struct RequestInfo *request_info;
|
||||||
CURL *http_handle = curl_msg->easy_handle;
|
CURL *http_handle = curl_msg->easy_handle;
|
||||||
curl_easy_getinfo(http_handle, CURLINFO_PRIVATE, &request_info);
|
curl_easy_getinfo(http_handle, CURLINFO_PRIVATE, &request_info);
|
||||||
|
if (!request_info->headers_received) {
|
||||||
|
forward_headers(request_info);
|
||||||
|
}
|
||||||
|
|
||||||
int error = (int) curl_msg->data.result;
|
int error = (int) curl_msg->data.result;
|
||||||
long response_code;
|
long response_code;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue