From 16dadf34d9feeb3d1812f3e066f4d3abd354f35d Mon Sep 17 00:00:00 2001 From: Anjali Nijhara Date: Wed, 15 Feb 2023 15:50:56 +0530 Subject: [PATCH] Check both CURLINFO_RESPONSE_CODE and CURLINFO_HTTP_CONNECTCODE for HTTP status code Change-Id: I2e78b92dd4223dcaec60408b67922fc72d52d3ee --- agent/download-agent-plugin-libcurl.c | 9 +++++---- packaging/download-provider.spec | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/agent/download-agent-plugin-libcurl.c b/agent/download-agent-plugin-libcurl.c index a0444c0..622c06d 100755 --- a/agent/download-agent-plugin-libcurl.c +++ b/agent/download-agent-plugin-libcurl.c @@ -180,18 +180,19 @@ void __store_header(void *msg, da_info_t *da_info, size_t header_size, 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 ca9496f..56bc876 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.2.14 +Version: 2.2.15 Release: 0 Group: Development/Libraries License: Apache-2.0 -- 2.7.4