[UTC][http][Non-ACR][Add exception for handling proxy] 96/228096/1
authorSeonah Moon <seonah1.moon@samsung.com>
Thu, 19 Mar 2020 04:21:45 +0000 (13:21 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Thu, 19 Mar 2020 04:24:43 +0000 (13:24 +0900)
Change-Id: I4a35944481fa33c60cd383fd281c3caa21f0272f
Signed-off-by: Seonah Moon <seonah1.moon@samsung.com>
src/utc/http/utc-network-http.c

index 67ca695e471a17ab1127fc3f0a9f26ff923d7e9e..e7d414ff3fdb4f91afa815ce2ccf00e1dc7217e2 100755 (executable)
@@ -39,6 +39,7 @@ static bool is_init = false;
 #ifdef WEARABLE
 static bool g_internet_supported = true;
 #endif
+static bool g_use_proxy = false;
 
 void __transaction_header_cb(http_transaction_h transaction, char *header, size_t header_len, void *user_data)
 {
@@ -93,6 +94,22 @@ void _register_callbacks(http_transaction_h transaction)
        http_transaction_set_aborted_cb(transaction, __transaction_aborted_cb, NULL);
 }
 
+void _get_proxy_info(void)
+{
+       connection_h connection = NULL;
+       char *proxy_addr = NULL;
+
+       if (connection_create(&connection) < 0)
+               return;
+
+       if (connection_get_proxy(connection, CONNECTION_ADDRESS_FAMILY_IPV4, &proxy_addr) < 0)
+               return;
+
+       if (proxy_addr) {
+               g_use_proxy = true;
+               free(proxy_addr);
+       }
+}
 
 /**
  * @function           utc_network_http_startup
@@ -107,6 +124,8 @@ void utc_http_startup(void)
 #ifdef WEARABLE
        system_info_get_platform_bool("http://tizen.org/feature/network.internet", &g_internet_supported);
 #endif
+       _get_proxy_info();
+
        if (!is_init) {
                ret = http_init();
                if (ret != HTTP_ERROR_NONE)
@@ -2811,7 +2830,16 @@ int utc_http_transaction_submit_n2(void)
        g_main_loop_run(g_pMainLoop);
        g_pMainLoop = NULL;
 
-       assert_eq(g_CallbackRet, HTTP_ERROR_COULDNT_RESOLVE_HOST);
+       if (g_use_proxy) {
+               // proxy server might not return response when URL isn't valid.
+               if (g_CallbackRet == HTTP_ERROR_OPERATION_FAILED
+                               || g_CallbackRet == HTTP_ERROR_COULDNT_RESOLVE_HOST)
+                       return 0;
+               else
+                       return 1;
+       } else {
+               assert_eq(g_CallbackRet, HTTP_ERROR_COULDNT_RESOLVE_HOST);
+       }
 
        return 0;
 }