From 0297f9c5e412ff62ff20114c3ab1bee27b85af81 Mon Sep 17 00:00:00 2001 From: Anjali Nijhara Date: Tue, 14 Feb 2023 13:37:55 +0530 Subject: [PATCH] Check both CURLINFO_RESPONSE_CODE and CURLINFO_HTTP_CONNECTCODE for HTTP status code Change-Id: Ic2330d88faf61e441e2384400ff9aede3f1fc538 --- agent/download-agent-plugin-libcurl.c | 11 +++++++---- packaging/download-provider.spec | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/agent/download-agent-plugin-libcurl.c b/agent/download-agent-plugin-libcurl.c index e3023dd..622c06d 100755 --- a/agent/download-agent-plugin-libcurl.c +++ b/agent/download-agent-plugin-libcurl.c @@ -179,17 +179,20 @@ void __store_header(void *msg, da_info_t *da_info, size_t header_size, CURL *curl; http_raw_data_t *raw_data = DA_NULL; curl = http_info->http_msg->curl; - if (http_info->proxy_info) { + + res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status); + if (status == 0 && http_info->proxy_info) { DA_LOGI("Proxy is set."); res = curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &status); - } else { - res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status); } + + DA_LOGI("status code[%d]", (int)status); + if (res != CURLE_OK) { DA_LOGE("Fail to get response status code"); return; } - DA_LOGI("status code[%d]", (int)status); + if (http_info->http_msg_response) http_info->http_msg_response->status_code = (int)status; raw_data = (http_raw_data_t *)calloc(1, sizeof(http_raw_data_t)); diff --git a/packaging/download-provider.spec b/packaging/download-provider.spec index 2e50fcf..ba4f7a4 100755 --- a/packaging/download-provider.spec +++ b/packaging/download-provider.spec @@ -1,6 +1,6 @@ Name: download-provider Summary: Download the contents in background -Version: 2.3.7 +Version: 2.3.8 Release: 0 Group: Development/Libraries License: Apache-2.0 -- 2.7.4