Get status code using CURLINFO_HTTP_CONNECTCODE when using proxy 18/287618/1
authorAnjali Nijhara <a.nijhara@samsung.com>
Wed, 1 Feb 2023 06:58:50 +0000 (12:28 +0530)
committerAnjali Nijhara <a.nijhara@samsung.com>
Wed, 1 Feb 2023 06:58:50 +0000 (12:28 +0530)
Change-Id: I93309e8c3ba38e0e7c70b389ac8c6e6caa80b258

agent/download-agent-plugin-libcurl.c

index 4d015ed..b1a5398 100755 (executable)
@@ -179,12 +179,17 @@ 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) {
+                       DA_LOGI("Proxy is set.");
+                       res = curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &status);
+               } else {
                res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
+               }
                if (res != CURLE_OK) {
                        DA_LOGE("Fail to get response status code");
                        return;
                }
-               DA_LOGV("status code[%d]", (int)status);
+               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));
@@ -307,6 +312,7 @@ da_ret_t __set_proxy_on_soup_session(proxy_info_t *proxy_info, CURL *curl)
        if (proxy_info && strlen(proxy_info->addr) > 0) {
                if (!strstr(proxy_info->addr, "0.0.0.0")) {
                        curl_easy_setopt(curl, CURLOPT_PROXY, proxy_info->addr);
+                       DA_LOGI("proxy[%s] is used.", proxy_info->addr);
                        if (proxy_info->user_name || proxy_info->password)
                                curl_easy_setopt(curl, CURLOPT_PROXYAUTH, CURLAUTH_ANY);
                        if (proxy_info->user_name)