Add cache support
[platform/framework/web/download-provider.git] / agent / download-agent-http-msg-handler.c
index cc21267..4686809 100755 (executable)
@@ -24,9 +24,9 @@
 #include "download-agent-encoding.h"
 
 // '.' and ';' are request from Vodafone
-#define IS_TERMINATING_CHAR(c)                 ( ((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
-#define IS_TERMINATING_CHAR_EX(c)              ( ((c) == '"') || ((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
-#define IS_URI_TERMINATING_CHAR(c)             ( ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
+#define IS_TERMINATING_CHAR(c)                 (((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20))
+#define IS_TERMINATING_CHAR_EX(c)              (((c) == '"') || ((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20))
+#define IS_URI_TERMINATING_CHAR(c)             (((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20))
 
 enum parsing_type {
        WITH_PARSING_OPTION,
@@ -34,19 +34,19 @@ enum parsing_type {
 };
 
 static da_ret_t __http_header_add_field(http_header_t **head,
-       const char *field, const char *value, enum parsing_type type);
+               const char *field, const char *value, enum parsing_type type);
 static void __http_header_destroy_all_field(http_header_t **head);
 static da_bool_t __get_http_header_for_field(
-       http_msg_response_t *http_msg_response, const char *in_field,
-       http_header_t **out_header);
+               http_msg_response_t *http_msg_response, const char *in_field,
+               http_header_t **out_header);
 static void __exchange_header_value(http_header_t *header,
-       const char *in_raw_value);
+               const char *in_raw_value);
 static http_header_options_t *__create_http_header_option(const char *field,
-       const char *value);
+               const char *value);
 static void __http_header_destroy_all_option(http_header_options_t **head);
 static da_bool_t __get_http_header_option_for_field(
-       http_header_options_t *header_option, const char *in_field,
-       char **out_value);
+               http_header_options_t *header_option, const char *in_field,
+               char **out_value);
 static http_header_options_t *__parsing_N_create_option_str(char *org_str);
 static http_header_options_t *__parsing_options(char *org_str);
 static void __parsing_raw_value(http_header_t *http_header);
@@ -55,10 +55,10 @@ da_ret_t http_msg_request_create(http_msg_request_t **http_msg_request)
 {
        http_msg_request_t *temp_http_msg_request = NULL;
 
-//     DA_LOGV("");
+       //      DA_LOGV("");
 
        temp_http_msg_request = (http_msg_request_t *)calloc(1,
-               sizeof(http_msg_request_t));
+                       sizeof(http_msg_request_t));
        if (!temp_http_msg_request) {
                *http_msg_request = NULL;
                DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
@@ -71,7 +71,7 @@ da_ret_t http_msg_request_create(http_msg_request_t **http_msg_request)
        temp_http_msg_request->http_body = NULL;
 
        *http_msg_request = temp_http_msg_request;
-       DA_LOGV( "http_msg_request: %x", (unsigned int)(*http_msg_request));
+       DA_LOGV("http_msg_request: %x", (unsigned int)(*http_msg_request));
 
        return DA_RESULT_OK;
 }
@@ -102,7 +102,7 @@ void http_msg_request_destroy(http_msg_request_t **http_msg_request)
 }
 
 da_ret_t http_msg_request_set_url(http_msg_request_t *http_msg_request,
-       const char *url)
+               const char *url)
 {
        DA_LOGV("");
 
@@ -122,7 +122,7 @@ da_ret_t http_msg_request_set_url(http_msg_request_t *http_msg_request,
 }
 
 da_ret_t http_msg_request_get_url(http_msg_request_t *http_msg_request,
-       const char **url)
+               const char **url)
 {
        DA_LOGV("");
 
@@ -141,7 +141,7 @@ da_ret_t http_msg_request_get_url(http_msg_request_t *http_msg_request,
 }
 
 da_ret_t http_msg_request_add_field(http_msg_request_t *http_msg_request,
-       const char *field, const char *value)
+               const char *field, const char *value)
 {
        //      DA_LOGV("");
 
@@ -160,7 +160,7 @@ da_ret_t http_msg_response_create(http_msg_response_t **http_msg_response)
        DA_LOGV("");
 
        temp_http_msg_response = (http_msg_response_t *)calloc(1,
-               sizeof(http_msg_response_t));
+                       sizeof(http_msg_response_t));
        if (!temp_http_msg_response) {
                DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
                return DA_ERR_FAIL_TO_MEMALLOC;
@@ -185,7 +185,7 @@ void http_msg_response_destroy(http_msg_response_t **http_msg_response)
 }
 
 da_ret_t http_msg_response_add_field(http_msg_response_t *http_msg_response,
-       const char *field, const char *value)
+               const char *field, const char *value)
 {
        DA_LOGV("");
 
@@ -197,7 +197,7 @@ da_ret_t http_msg_response_add_field(http_msg_response_t *http_msg_response,
 }
 
 da_ret_t __http_header_add_field(http_header_t **head,
-       const char *field, const char *value, enum parsing_type type)
+               const char *field, const char *value, enum parsing_type type)
 {
        http_header_t *pre = NULL;
        http_header_t *cur = NULL;
@@ -209,7 +209,7 @@ da_ret_t __http_header_add_field(http_header_t **head,
                pre = cur;
                /* Replace default value with user wanted value
                 * Remove the value which is stored before and add a new value.
-               */
+                */
                if (cur->field && cur->raw_value &&
                                strncasecmp(cur->field, field, strlen(field)) == 0) {
                        DA_SECURE_LOGD("Remove value for replacement [%s][%s]", cur->field, cur->raw_value);
@@ -219,7 +219,7 @@ da_ret_t __http_header_add_field(http_header_t **head,
                        }
                        if (cur->raw_value) {
                                free(cur->raw_value);
-                               cur->raw_value= NULL;
+                               cur->raw_value = NULL;
                        }
                }
                cur = cur->next;
@@ -282,12 +282,12 @@ void __http_header_destroy_all_field(http_header_t **head)
 }
 
 http_header_options_t *__create_http_header_option(const char *field,
-       const char *value)
+               const char *value)
 {
        http_header_options_t *option = NULL;
 
        option = (http_header_options_t *)calloc(1,
-               sizeof(http_header_options_t));
+                       sizeof(http_header_options_t));
        if (option) {
                if (field)
                        option->field = strdup(field);
@@ -325,7 +325,7 @@ void __http_header_destroy_all_option(http_header_options_t **head)
 }
 
 da_ret_t http_msg_request_get_iter(http_msg_request_t *http_msg_request,
-       http_msg_iter_t *http_msg_iter)
+               http_msg_iter_t *http_msg_iter)
 {
        DA_LOGV("");
 
@@ -340,7 +340,7 @@ da_ret_t http_msg_request_get_iter(http_msg_request_t *http_msg_request,
 }
 
 da_ret_t http_msg_response_get_iter(http_msg_response_t *http_msg_response,
-       http_msg_iter_t *http_msg_iter)
+               http_msg_iter_t *http_msg_iter)
 {
        if (!http_msg_response) {
                DA_LOGE("DA_ERR_INVALID_ARGUMENT");
@@ -352,7 +352,7 @@ da_ret_t http_msg_response_get_iter(http_msg_response_t *http_msg_response,
 }
 
 da_bool_t http_msg_get_field_with_iter(http_msg_iter_t *http_msg_iter,
-       char **out_field, char **out_value)
+               char **out_field, char **out_value)
 {
        http_header_t *cur = *http_msg_iter;
 
@@ -367,7 +367,7 @@ da_bool_t http_msg_get_field_with_iter(http_msg_iter_t *http_msg_iter,
 }
 
 da_bool_t http_msg_get_header_with_iter(http_msg_iter_t *http_msg_iter,
-       char **out_field, http_header_t **out_header)
+               char **out_field, http_header_t **out_header)
 {
        http_header_t *cur = *http_msg_iter;
 
@@ -447,13 +447,13 @@ http_header_options_t *__parsing_N_create_option_str(char *org_str)
                option_field = (char *)calloc(1, option_field_len + 1);
                if (option_field)
                        strncpy(option_field, working_pos_field_start,
-                               option_field_len);
+                                       option_field_len);
        }
        if (option_value_len > 0 && working_pos_value_start) {
                option_value = (char *)calloc(1, option_value_len + 1);
                if (option_value)
                        strncpy(option_value, working_pos_value_start,
-                               option_value_len);
+                                       option_value_len);
        }
        if (working_str) {
                free(working_str);
@@ -461,11 +461,12 @@ http_header_options_t *__parsing_N_create_option_str(char *org_str)
        }
 
        DA_SECURE_LOGD("option_field = [%s], option_value = [%s]",
-               option_field, option_value);
+                       option_field ? option_field : "",
+                       option_value ? option_value : "");
 
        if (option_field || option_value) {
                option = __create_http_header_option(
-                       option_field, option_value);
+                               option_field, option_value);
                if (option_field) {
                        free(option_field);
                        option_field = NULL;
@@ -581,14 +582,14 @@ void __parsing_raw_value(http_header_t *http_header_field)
        http_header_options_t *cur = NULL;
        cur = http_header_field->options;
        while (cur) {
-//             DA_SECURE_LOGD("field = [%s], value = [%s]", cur->field, cur->value);
+               //              DA_SECURE_LOGD("field = [%s], value = [%s]", cur->field, cur->value);
                cur = cur->next;
        }
 }
 
 da_bool_t __get_http_header_option_for_field(
-       http_header_options_t *header_option, const char *in_field,
-       char **out_value)
+               http_header_options_t *header_option, const char *in_field,
+               char **out_value)
 {
        http_header_options_t *cur = NULL;
 
@@ -616,9 +617,9 @@ da_bool_t __get_http_header_option_for_field(
 }
 
 da_bool_t __get_http_header_for_field(http_msg_response_t *http_msg_response,
-       const char *in_field, http_header_t **out_header)
+               const char *in_field, http_header_t **out_header)
 {
-       http_msg_iter_t http_msg_iter;
+       http_msg_iter_t http_msg_iter = DA_NULL;
        http_header_t *header = NULL;
        char *field = NULL;
 
@@ -637,9 +638,9 @@ da_bool_t __get_http_header_for_field(http_msg_response_t *http_msg_response,
 }
 
 da_bool_t __get_http_req_header_for_field(http_msg_request_t *http_msg_request,
-       const char *in_field, http_header_t **out_header)
+               const char *in_field, http_header_t **out_header)
 {
-       http_msg_iter_t http_msg_iter;
+       http_msg_iter_t http_msg_iter = DA_NULL;
        http_header_t *header = NULL;
        char *field = NULL;
 
@@ -678,7 +679,7 @@ void __exchange_header_value(http_header_t *header, const char *in_raw_value)
 }
 
 da_bool_t http_msg_response_get_content_type(
-       http_msg_response_t *http_msg_response, char **out_type)
+               http_msg_response_t *http_msg_response, char **out_type)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -698,7 +699,7 @@ da_bool_t http_msg_response_get_content_type(
 }
 
 void http_msg_response_set_content_type(http_msg_response_t *http_msg_response,
-       const char *in_type)
+               const char *in_type)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -711,8 +712,7 @@ void http_msg_response_set_content_type(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_CONTENT_TYPE, &header);
        if (b_ret) {
-               if (header->raw_value && (!strncmp(header->raw_value, in_type,
-                       strlen(header->raw_value))))
+               if (header->raw_value && !strcmp(header->raw_value, in_type))
                        return;
 
                DA_SECURE_LOGD("exchange Content-Type to [%s] from [%s]", in_type, header->value);
@@ -724,7 +724,7 @@ void http_msg_response_set_content_type(http_msg_response_t *http_msg_response,
 }
 
 da_bool_t http_msg_response_get_content_length(
-       http_msg_response_t *http_msg_response, da_size_t *out_length)
+               http_msg_response_t *http_msg_response, da_size_t *out_length)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -734,7 +734,7 @@ da_bool_t http_msg_response_get_content_length(
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_CONTENT_LENGTH, &header);
        if (!b_ret) {
-               DA_LOGV( "no Content-Length");
+               DA_LOGV("no Content-Length");
                return DA_FALSE;
        }
 
@@ -745,8 +745,8 @@ da_bool_t http_msg_response_get_content_length(
 }
 
 da_bool_t http_msg_response_get_content_disposition(
-       http_msg_response_t *http_msg_response, http_msg_t *http_msg, char **out_disposition,
-       char **out_file_name)
+               http_msg_response_t *http_msg_response, http_msg_t *http_msg, char **out_disposition,
+               char **out_file_name)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -762,7 +762,7 @@ da_bool_t http_msg_response_get_content_disposition(
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_CONTENT_DISPOSITION, &header);
        if (!b_ret) {
-               DA_LOGV( "no Content-Disposition");
+               DA_LOGV("no Content-Disposition");
                return DA_FALSE;
        }
        if (out_disposition)
@@ -771,9 +771,9 @@ da_bool_t http_msg_response_get_content_disposition(
                return DA_FALSE;
 
        b_ret = __get_http_header_option_for_field(header->options, "filename",
-               &file_name);
+                       &file_name);
        if (!b_ret) {
-               DA_LOGV( "no option");
+               DA_LOGV("no option");
                return DA_FALSE;
        }
 
@@ -799,7 +799,7 @@ da_bool_t http_msg_response_get_content_disposition(
                        if (b_ret) {
                                DA_LOGV("It's base64 encoded-word string");
                                if (DA_RESULT_OK == decode_base64_encoded_str(
-                                       wanted_str, &decoded_str)) {
+                                                       wanted_str, &decoded_str)) {
                                        DA_SECURE_LOGD("base64 decoded str = [%s]", decoded_str);
                                        free(wanted_str);
                                        wanted_str = decoded_str;
@@ -811,10 +811,9 @@ da_bool_t http_msg_response_get_content_disposition(
                                DA_LOGV("It's NOT base64 encoded-word string");
                        }
 
-                       if(http_msg->curl){
+                       if (http_msg->curl) {
                                decoded_str = curl_easy_unescape(http_msg->curl, wanted_str, wanted_str_len, NULL);
-                       }
-                       else{
+                       } else{
                                CURL* handle = curl_easy_init();
                                decoded_str = curl_easy_unescape(handle, wanted_str, wanted_str_len, NULL);
                                curl_easy_cleanup(handle);
@@ -824,17 +823,14 @@ da_bool_t http_msg_response_get_content_disposition(
                        if (decoded_str) {
                                char* file_name;
                                DA_SECURE_LOGD("Url decoded str = [%s]", decoded_str);
-                               file_name = (char*)calloc(1, strlen(decoded_str) + 1);
-                               strncpy(file_name, decoded_str, strlen(decoded_str));
-
+                               file_name = strdup(decoded_str);
                                NULL_CHECK_AND_FREE(wanted_str);
                                curl_free(decoded_str);
                                decoded_str = NULL;
 
                                *out_file_name = file_name;
                                return DA_TRUE;
-                       }
-                       else{
+                       } else{
                                DA_LOGE("Fail to url decode.");
                                NULL_CHECK_AND_FREE(wanted_str);
                                *out_file_name = NULL;
@@ -847,8 +843,7 @@ da_bool_t http_msg_response_get_content_disposition(
        }
 }
 
-da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response,
-       char **out_value)
+da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response, char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -858,7 +853,7 @@ da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response, HTTP_FIELD_ETAG,
                        &header);
        if (!b_ret) {
-               DA_LOGV( "no ETag");
+               DA_LOGV("no ETag");
                return DA_FALSE;
        }
        if (out_value)
@@ -867,9 +862,58 @@ da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response,
        return DA_TRUE;
 }
 
+da_bool_t http_msg_response_get_cache_control(http_msg_response_t *http_msg_response, char **out_value)
+{
+       da_bool_t b_ret = DA_FALSE;
+       http_header_t *header = NULL;
+
+       if (!out_value) {
+               DA_LOGE("[NULL CHECK] out_value");
+               return DA_FALSE;
+       }
+
+       b_ret = __get_http_header_for_field(http_msg_response, HTTP_FIELD_CACHE_CONTROL,
+                       &header);
+       if (!b_ret) {
+               DA_LOGV("no cache-control");
+               return DA_FALSE;
+       }
+
+       if (header->value)
+               *out_value = strdup(header->value);
+       else
+               return DA_FALSE;
+
+       return DA_TRUE;
+}
+
+da_bool_t http_msg_response_get_last_modified(http_msg_response_t *http_msg_response, char **out_value)
+{
+       da_bool_t b_ret = DA_FALSE;
+       http_header_t *header = NULL;
+
+       if (!out_value) {
+               DA_LOGE("[NULL CHECK] out_value");
+               return DA_FALSE;
+       }
+
+       b_ret = __get_http_header_for_field(http_msg_response, HTTP_FIELD_LAST_MODIFIED,
+                       &header);
+       if (!b_ret) {
+               DA_LOGV("no last-modified");
+               return DA_FALSE;
+       }
+       if (header->value)
+               *out_value = strdup(header->value);
+       else
+               return DA_FALSE;
+
+       return DA_TRUE;
+}
+
 #ifdef _RAF_SUPPORT
 da_bool_t http_msg_response_get_RAF_mode(http_msg_response_t *http_msg_response,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -879,7 +923,7 @@ da_bool_t http_msg_response_get_RAF_mode(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response, HTTP_FIELD_RAF_MODE,
                        &header);
        if (!b_ret) {
-               DA_LOGV( "no RAF mode");
+               DA_LOGV("no RAF mode");
                return DA_FALSE;
        }
        if (out_value)
@@ -890,7 +934,7 @@ da_bool_t http_msg_response_get_RAF_mode(http_msg_response_t *http_msg_response,
 #endif
 
 da_bool_t http_msg_response_get_date(http_msg_response_t *http_msg_response,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -900,7 +944,7 @@ da_bool_t http_msg_response_get_date(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_DATA, &header);
        if (!b_ret) {
-               DA_LOGV( "no Date");
+               DA_LOGV("no Date");
                return DA_FALSE;
        }
        if (out_value)
@@ -910,7 +954,7 @@ da_bool_t http_msg_response_get_date(http_msg_response_t *http_msg_response,
 }
 
 da_bool_t http_msg_response_get_location(http_msg_response_t *http_msg_response,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -920,7 +964,27 @@ da_bool_t http_msg_response_get_location(http_msg_response_t *http_msg_response,
        b_ret = __get_http_header_for_field(http_msg_response,
                        HTTP_FIELD_LOCATION, &header);
        if (!b_ret) {
-               DA_LOGV( "no Location");
+               DA_LOGV("no Location");
+               return DA_FALSE;
+       }
+       if (out_value)
+               *out_value = strdup(header->value);
+
+       return DA_TRUE;
+}
+
+da_bool_t http_msg_response_get_transfer_encoding(http_msg_response_t *http_msg_response,
+               char **out_value)
+{
+       da_bool_t b_ret = DA_FALSE;
+       http_header_t *header = NULL;
+
+       DA_LOGV("");
+
+       b_ret = __get_http_header_for_field(http_msg_response,
+                       HTTP_FIELD_TRANSFER_ENCODING, &header);
+       if (!b_ret) {
+               DA_LOGE("no Transfer-Encoding");
                return DA_FALSE;
        }
        if (out_value)
@@ -963,11 +1027,10 @@ char *__stristr(const char *long_str, const char *find_str)
 
        while (i < length_long) {
                if (isalpha(long_str[i]) != 0) {
-                       if (isupper(long_str[i]) != 0) {
+                       if (isupper(long_str[i]) != 0)
                                org_ptr[i] = long_str[i];
-                       } else {
+                       else
                                org_ptr[i] = toupper(long_str[i]);
-                       }
                } else {
                        org_ptr[i] = long_str[i];
                }
@@ -978,11 +1041,10 @@ char *__stristr(const char *long_str, const char *find_str)
 
        while (i < length_find) {
                if (isalpha(find_str[i]) != 0) {
-                       if (isupper(find_str[i]) != 0) {
+                       if (isupper(find_str[i]) != 0)
                                look_ptr[i] = find_str[i];
-                       } else {
+                       else
                                look_ptr[i] = toupper(find_str[i]);
-                       }
                } else {
                        look_ptr[i] = find_str[i];
                }
@@ -1007,9 +1069,9 @@ char *__stristr(const char *long_str, const char *find_str)
 
 /* This is not used. But it can be needed if there is no http header parser at http library.*/
 da_bool_t extract_attribute_from_header(
-        char *szHeadStr,
-        const char *szFindStr,
-        char **ppRtnValue)
+               char *szHeadStr,
+               const char *szFindStr,
+               char **ppRtnValue)
 {
        char *pValuePos = NULL;
        int index = 0;
@@ -1026,9 +1088,8 @@ da_bool_t extract_attribute_from_header(
 
                return DA_FALSE;
        }
-       if (ppRtnValue == NULL) {
+       if (ppRtnValue == NULL)
                return DA_FALSE;
-       }
 
        pValuePos = __stristr(szHeadStr, (char*)szFindStr);
        if (pValuePos == NULL) {
@@ -1041,17 +1102,15 @@ da_bool_t extract_attribute_from_header(
        while (pValuePos[index] != ':' && pValuePos[index] != '=') {
                index++;
 
-               if (pValuePos[index] == '\0') {
+               if (pValuePos[index] == '\0')
                        return DA_FALSE;
-               }
        }
 
        index++;
 
        /* jump space */
-       while (pValuePos[index] == ' ') {
+       while (pValuePos[index] == ' ')
                index++;
-       }
 
        /* jump quatation mark */
        while (pValuePos[index] == '"') {
@@ -1061,21 +1120,18 @@ da_bool_t extract_attribute_from_header(
 
        startPos = index;
 
-       /* Find the end of data. */
-       if (0 == strncasecmp(szFindStr, HTTP_FIELD_LOCATION,
-                       strlen(HTTP_FIELD_LOCATION)))//terminate character list does not contain ';' in case of URI
-       {
-               while (DA_FALSE == IS_URI_TERMINATING_CHAR(pValuePos[index])) {
+       /* Find the end of data.
+        * terminate character list does not contain ';' in case of URI
+        */
+       if (0 == strncasecmp(szFindStr, HTTP_FIELD_LOCATION, strlen(HTTP_FIELD_LOCATION))) {
+               while (DA_FALSE == IS_URI_TERMINATING_CHAR(pValuePos[index]))
                        index++;
-               }
        } else if (need_to_end_quataion_mark) {
-               while (DA_FALSE == IS_TERMINATING_CHAR_EX(pValuePos[index])) {
+               while (DA_FALSE == IS_TERMINATING_CHAR_EX(pValuePos[index]))
                        index++;
-               }
        } else {
-               while (DA_FALSE == IS_TERMINATING_CHAR(pValuePos[index])) {
+               while (DA_FALSE == IS_TERMINATING_CHAR(pValuePos[index]))
                        index++;
-               }
        }
 
        strLen = index - startPos;
@@ -1105,7 +1161,7 @@ ERR:
 }
 
 da_bool_t http_msg_request_get_if_range(http_msg_request_t *http_msg_request,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -1115,7 +1171,7 @@ da_bool_t http_msg_request_get_if_range(http_msg_request_t *http_msg_request,
        b_ret = __get_http_req_header_for_field(http_msg_request, HTTP_FIELD_IF_RANGE,
                        &header);
        if (!b_ret) {
-               DA_LOGV( "no If Range");
+               DA_LOGV("no If Range");
                return DA_FALSE;
        }
        if (out_value)
@@ -1125,7 +1181,7 @@ da_bool_t http_msg_request_get_if_range(http_msg_request_t *http_msg_request,
 }
 
 da_bool_t http_msg_request_get_range(http_msg_request_t *http_msg_request,
-       char **out_value)
+               char **out_value)
 {
        da_bool_t b_ret = DA_FALSE;
        http_header_t *header = NULL;
@@ -1135,7 +1191,7 @@ da_bool_t http_msg_request_get_range(http_msg_request_t *http_msg_request,
        b_ret = __get_http_req_header_for_field(http_msg_request, HTTP_FIELD_RANGE,
                        &header);
        if (!b_ret) {
-               DA_LOGV( "no Range");
+               DA_LOGV("no Range");
                return DA_FALSE;
        }
        if (out_value)