#include <string.h>
#include <errno.h>
#include <time.h>
+#include <vconf.h>
#include "download-agent-dl-info.h"
#include "download-agent-file.h"
#define CONVERT_STR(NAME) (#NAME)
+#define VCONF_KEY_PROXY_EXCEPTION_LIST "db/menu/network/server_network_settings/proxy_exceptional_address"
+#define PROXY_EXCEPTION_LIST_DELIMITER ";"
+#define HTTP_PREFIX "http://"
+#define HTTPS_PREFIX "https://"
+
static const char *__get_state_str(http_state_t state)
{
char *str = NULL;
return str;
}
+// 0: not required, 1: required
+static int __is_proxy_required(char *url)
+{
+ char *parsed_url = NULL;
+ char *exception_list = vconf_get_str(VCONF_KEY_PROXY_EXCEPTION_LIST);
+ char *ptr = NULL;
+ char *next_ptr = NULL;
+ char *next_ptr2 = NULL;
+
+ if (!exception_list)
+ return 1;
+
+ DA_LOGI("proxy exception list[%s]", exception_list);
+
+ if (url && strstr(url, HTTP_PREFIX))
+ parsed_url = url + strlen(HTTP_PREFIX);
+ else if (url && strstr(url, HTTPS_PREFIX))
+ parsed_url = url + strlen(HTTPS_PREFIX);
+ else
+ parsed_url = url;
+
+ DA_LOGI("compared url[%s] parsed url[%s]", url, parsed_url);
+
+ ptr = strtok_r(exception_list, PROXY_EXCEPTION_LIST_DELIMITER, &next_ptr);
+ while (ptr) {
+ // Ignore protocol prefix
+ if (strstr(ptr, HTTP_PREFIX))
+ ptr = ptr + strlen(HTTP_PREFIX);
+ else if (strstr(ptr, HTTPS_PREFIX))
+ ptr = ptr + strlen(HTTPS_PREFIX);
+
+ // Remove file path
+ if (ptr && strstr(ptr, "/"))
+ ptr = strtok_r(ptr, "/", &next_ptr2);
+
+ if (ptr && strncmp(parsed_url, ptr, strlen(ptr)) == 0) {
+ DA_LOGI("[%s/%s] is exist in exception list.", url, ptr);
+ free(exception_list);
+ return 0;
+ }
+
+ ptr = strtok_r(NULL, PROXY_EXCEPTION_LIST_DELIMITER, &next_ptr);
+ }
+
+ free(exception_list);
+
+ DA_LOGI("There is no matched address in exception list");
+
+ return 1;
+}
+
void __init_http_info(http_info_t *http_info)
{
DA_LOGV("");
return DA_ERR_INVALID_ARGUMENT;
}
http_info->http_method = HTTP_METHOD_GET;
- http_info->proxy_info = __get_proxy_info();
+
+ // Check exception list for proxy
+ if (__is_proxy_required(da_info->req_info->url))
+ http_info->proxy_info = __get_proxy_info();
+ else
+ http_info->proxy_info = NULL;
ret = PI_http_start(da_info);
}
} else {
proxy_info->addr = strdup(proxy_uri);
+ DA_LOGI("proxy_info->addr[%s] will be used.", proxy_info->addr);
}
proxy_info->user_name = strlen(user_name) > 0 ? strdup(user_name) : DA_NULL;
proxy_info->password = strlen(password) > 0 ? strdup(password) : DA_NULL;
if (proxy_uri)
free(proxy_uri);
- DA_LOGD("host[%s] user_name[%s] password[***]", host, user_name);
+ DA_LOGI("host[%s] user_name[%s] password[***]", host, user_name);
return proxy_info;
}
switch (type) {
case CURLINFO_TEXT:
if (data)
- DA_SECURE_LOGI("[curl] Info:%s", data);
+ DA_LOGI("[curl] Info:%s", data);
break;
case CURLINFO_HEADER_OUT:
- DA_LOGD("[curl] Send header");
+ DA_LOGI("[curl] Send header");
if (data)
DA_SECURE_LOGI("[curl] %s", data);
break;
case CURLINFO_DATA_OUT:
- DA_LOGD("[curl] Send data");
+ DA_LOGI("[curl] Send data");
if (data)
DA_SECURE_LOGI("[curl] %s", data);
break;
case CURLINFO_SSL_DATA_OUT:
- DA_LOGD("[curl] Send SSL data");
+ DA_LOGI("[curl] Send SSL data");
break;
case CURLINFO_HEADER_IN:
- DA_LOGD("[curl] Recv header");
+ DA_LOGI("[curl] Recv header");
if (data)
DA_SECURE_LOGI("[curl] %s", data);
break;
case CURLINFO_SSL_DATA_IN:
- DA_SECURE_LOGI("[curl] Recv SSL data");
+ DA_LOGI("[curl] Recv SSL data");
break;
default:
return 0;
DA_LOGI("Proxy is set.");
res = curl_easy_getinfo(curl, CURLINFO_HTTP_CONNECTCODE, &status);
} else {
- res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
+ res = curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &status);
}
if (res != CURLE_OK) {
DA_LOGE("Fail to get response status code");