From 7bc18cfea27b0c89835aac18e7d9ba1f371dabcf Mon Sep 17 00:00:00 2001 From: Anjali Nijhara Date: Tue, 14 Mar 2023 09:18:21 +0530 Subject: [PATCH] Check both CURLINFO_RESPONSE_CODE and CURLINFO_HTTP_CONNECTCODE for HTTP status code Change-Id: I1e1f7186d743d2bc8da4b33834d3f67e5698e3ec --- agent/download-agent-plugin-libcurl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/agent/download-agent-plugin-libcurl.c b/agent/download-agent-plugin-libcurl.c index 4a33de6..c4dd69a 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)); -- 2.7.4