Check both CURLINFO_RESPONSE_CODE and CURLINFO_HTTP_CONNECTCODE for HTTP status code 20/289720/1
authorAnjali Nijhara <a.nijhara@samsung.com>
Tue, 14 Mar 2023 03:48:21 +0000 (09:18 +0530)
committerAnjali Nijhara <a.nijhara@samsung.com>
Tue, 14 Mar 2023 03:48:21 +0000 (09:18 +0530)
Change-Id: I1e1f7186d743d2bc8da4b33834d3f67e5698e3ec

agent/download-agent-plugin-libcurl.c

index 4a33de6..c4dd69a 100755 (executable)
@@ -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));