2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 #include <curl/curl.h>
22 #include "download-agent-http-msg-handler.h"
23 #include "download-agent-debug.h"
24 #include "download-agent-encoding.h"
26 // '.' and ';' are request from Vodafone
27 #define IS_TERMINATING_CHAR(c) ( ((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
28 #define IS_TERMINATING_CHAR_EX(c) ( ((c) == '"') || ((c) == ';') || ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
29 #define IS_URI_TERMINATING_CHAR(c) ( ((c) == '\0') || ((c) == 0x0d) || ((c) == 0x0a) || ((c) == 0x20) )
33 WITHOUT_PARSING_OPTION
36 static da_ret_t __http_header_add_field(http_header_t **head,
37 const char *field, const char *value, enum parsing_type type);
38 static void __http_header_destroy_all_field(http_header_t **head);
39 static da_bool_t __get_http_header_for_field(
40 http_msg_response_t *http_msg_response, const char *in_field,
41 http_header_t **out_header);
42 static void __exchange_header_value(http_header_t *header,
43 const char *in_raw_value);
44 static http_header_options_t *__create_http_header_option(const char *field,
46 static void __http_header_destroy_all_option(http_header_options_t **head);
47 static da_bool_t __get_http_header_option_for_field(
48 http_header_options_t *header_option, const char *in_field,
50 static http_header_options_t *__parsing_N_create_option_str(char *org_str);
51 static http_header_options_t *__parsing_options(char *org_str);
52 static void __parsing_raw_value(http_header_t *http_header);
54 da_ret_t http_msg_request_create(http_msg_request_t **http_msg_request)
56 http_msg_request_t *temp_http_msg_request = NULL;
60 temp_http_msg_request = (http_msg_request_t *)calloc(1,
61 sizeof(http_msg_request_t));
62 if (!temp_http_msg_request) {
63 *http_msg_request = NULL;
64 DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
65 return DA_ERR_FAIL_TO_MEMALLOC;
68 temp_http_msg_request->http_method = NULL;
69 temp_http_msg_request->url = NULL;
70 temp_http_msg_request->head = NULL;
71 temp_http_msg_request->http_body = NULL;
73 *http_msg_request = temp_http_msg_request;
74 DA_LOGV( "http_msg_request: %x", (unsigned int)(*http_msg_request));
79 void http_msg_request_destroy(http_msg_request_t **http_msg_request)
81 http_msg_request_t *temp_http_msg_request = *http_msg_request;
85 if (temp_http_msg_request) {
86 if (temp_http_msg_request->http_method) {
87 free(temp_http_msg_request->http_method);
88 temp_http_msg_request->http_method = NULL;
90 if (temp_http_msg_request->url) {
91 free(temp_http_msg_request->url);
92 temp_http_msg_request->url = NULL;
94 if (temp_http_msg_request->http_body) {
95 free(temp_http_msg_request->http_body);
96 temp_http_msg_request->http_body = NULL;
98 __http_header_destroy_all_field(&(temp_http_msg_request->head));
99 free(*http_msg_request);
100 *http_msg_request = NULL;
104 da_ret_t http_msg_request_set_url(http_msg_request_t *http_msg_request,
109 if (!http_msg_request) {
110 DA_LOGE("http_msg_request is NULL; DA_ERR_INVALID_ARGUMENT");
111 return DA_ERR_INVALID_ARGUMENT;
115 DA_LOGE("url is NULL; DA_ERR_INVALID_ARGUMENT");
116 return DA_ERR_INVALID_URL;
119 http_msg_request->url = strdup(url);
120 DA_SECURE_LOGI("http url[%s]", http_msg_request->url);
124 da_ret_t http_msg_request_get_url(http_msg_request_t *http_msg_request,
129 if (!http_msg_request) {
130 DA_LOGE("http_msg_request is NULL; DA_ERR_INVALID_ARGUMENT");
131 return DA_ERR_INVALID_ARGUMENT;
134 if (http_msg_request->url) {
135 *url = http_msg_request->url;
139 return DA_ERR_INVALID_ARGUMENT;
143 da_ret_t http_msg_request_add_field(http_msg_request_t *http_msg_request,
144 const char *field, const char *value)
148 if (!http_msg_request) {
149 DA_LOGE("Check NULL! : http_msg_request");
150 return DA_ERR_INVALID_ARGUMENT;
153 return __http_header_add_field(&(http_msg_request->head), field, value, WITHOUT_PARSING_OPTION);
156 da_ret_t http_msg_response_create(http_msg_response_t **http_msg_response)
158 http_msg_response_t *temp_http_msg_response = NULL;
162 temp_http_msg_response = (http_msg_response_t *)calloc(1,
163 sizeof(http_msg_response_t));
164 if (!temp_http_msg_response) {
165 DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
166 return DA_ERR_FAIL_TO_MEMALLOC;
168 temp_http_msg_response->status_code = 0;
169 temp_http_msg_response->head = NULL;
170 *http_msg_response = temp_http_msg_response;
175 void http_msg_response_destroy(http_msg_response_t **http_msg_response)
177 http_msg_response_t *temp_http_msg_response = *http_msg_response;
180 if (temp_http_msg_response) {
181 __http_header_destroy_all_field(&(temp_http_msg_response->head));
182 free(*http_msg_response);
183 *http_msg_response = DA_NULL;
187 da_ret_t http_msg_response_add_field(http_msg_response_t *http_msg_response,
188 const char *field, const char *value)
192 if (!http_msg_response) {
193 DA_LOGE("DA_ERR_INVALID_ARGUMENT");
194 return DA_ERR_INVALID_ARGUMENT;
196 return __http_header_add_field(&(http_msg_response->head), field, value, WITH_PARSING_OPTION);
199 da_ret_t __http_header_add_field(http_header_t **head,
200 const char *field, const char *value, enum parsing_type type)
202 http_header_t *pre = NULL;
203 http_header_t *cur = NULL;
205 //DA_SECURE_LOGD("[%s][%s]", field, value);
210 /* Replace default value with user wanted value
211 * Remove the value which is stored before and add a new value.
213 if (cur->field && cur->raw_value &&
214 strncasecmp(cur->field, field, strlen(field)) == 0) {
215 DA_SECURE_LOGD("Remove value for replacement [%s][%s]", cur->field, cur->raw_value);
220 if (cur->raw_value) {
221 free(cur->raw_value);
222 cur->raw_value= NULL;
228 cur = (http_header_t *)calloc(1, sizeof(http_header_t));
230 cur->field = strdup(field);
231 cur->raw_value = strdup(value);
235 if (type == WITHOUT_PARSING_OPTION) {
236 cur->value = strdup(value);
239 __parsing_raw_value(cur);
247 DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
248 return DA_ERR_FAIL_TO_MEMALLOC;
254 void __http_header_destroy_all_field(http_header_t **head)
256 http_header_t *pre = NULL;
257 http_header_t *cur = NULL;
264 cur->field = DA_NULL;
268 cur->value = DA_NULL;
270 if (cur->raw_value) {
271 free(cur->raw_value);
272 cur->raw_value = DA_NULL;
274 __http_header_destroy_all_option(&(cur->options));
276 cur->options = DA_NULL;
284 http_header_options_t *__create_http_header_option(const char *field,
287 http_header_options_t *option = NULL;
289 option = (http_header_options_t *)calloc(1,
290 sizeof(http_header_options_t));
293 option->field = strdup(field);
295 option->value = strdup(value);
301 void __http_header_destroy_all_option(http_header_options_t **head)
303 http_header_options_t *pre = NULL;
304 http_header_options_t *cur = NULL;
312 DA_SECURE_LOGD("field= %s", cur->field);
314 cur->field = DA_NULL;
318 cur->value = DA_NULL;
327 da_ret_t http_msg_request_get_iter(http_msg_request_t *http_msg_request,
328 http_msg_iter_t *http_msg_iter)
332 if (!http_msg_request) {
333 DA_LOGE("DA_ERR_INVALID_ARGUMENT");
334 return DA_ERR_INVALID_ARGUMENT;
337 *http_msg_iter = http_msg_request->head;
342 da_ret_t http_msg_response_get_iter(http_msg_response_t *http_msg_response,
343 http_msg_iter_t *http_msg_iter)
345 if (!http_msg_response) {
346 DA_LOGE("DA_ERR_INVALID_ARGUMENT");
347 return DA_ERR_INVALID_ARGUMENT;
350 *http_msg_iter = http_msg_response->head;
354 da_bool_t http_msg_get_field_with_iter(http_msg_iter_t *http_msg_iter,
355 char **out_field, char **out_value)
357 http_header_t *cur = *http_msg_iter;
360 *out_field = cur->field;
361 *out_value = cur->value;
362 *http_msg_iter = cur->next;
369 da_bool_t http_msg_get_header_with_iter(http_msg_iter_t *http_msg_iter,
370 char **out_field, http_header_t **out_header)
372 http_header_t *cur = *http_msg_iter;
375 *out_field = cur->field;
377 *http_msg_iter = cur->next;
384 http_header_options_t *__parsing_N_create_option_str(char *org_str)
386 char *option_field = NULL;
387 char *option_value = NULL;
388 int option_field_len = 0;
389 int option_value_len = 0;
390 char *org_pos = NULL;
392 char *working_str = NULL;
393 char *working_pos = NULL;
394 char *working_pos_field_start = NULL;
395 char *working_pos_value_start = NULL;
396 da_bool_t is_inside_quotation = DA_FALSE;
397 da_bool_t is_working_for_field = DA_TRUE;
399 http_header_options_t *option = NULL;
406 org_str_len = strlen(org_str);
407 if (org_str_len <= 0)
410 working_str = (char *)calloc(1, org_str_len + 1);
415 working_pos_field_start = working_pos = working_str;
417 for (i = 0; i < org_str_len; i++) {
419 is_inside_quotation = !is_inside_quotation;
420 if (is_inside_quotation) {
421 // Leave anything including blank if it is inside of double quotation mark.
422 *working_pos = *org_pos;
423 is_working_for_field ? option_field_len++
424 : option_value_len++;
428 if (*org_pos == ' ') {
430 } else if (*org_pos == '=') {
431 if (is_working_for_field) {
432 is_working_for_field = DA_FALSE;
433 working_pos_value_start = working_pos;
437 *working_pos = *org_pos;
438 is_working_for_field ? option_field_len++
439 : option_value_len++;
446 if (option_field_len > 0 && working_pos_field_start) {
447 option_field = (char *)calloc(1, option_field_len + 1);
449 strncpy(option_field, working_pos_field_start,
452 if (option_value_len > 0 && working_pos_value_start) {
453 option_value = (char *)calloc(1, option_value_len + 1);
455 strncpy(option_value, working_pos_value_start,
460 working_pos = working_str = NULL;
463 DA_SECURE_LOGD("option_field = [%s], option_value = [%s]",
464 option_field, option_value);
466 if (option_field || option_value) {
467 option = __create_http_header_option(
468 option_field, option_value);
481 http_header_options_t *__parsing_options(char *org_str)
483 da_ret_t ret = DA_RESULT_OK;
484 http_header_options_t *head = NULL;
485 http_header_options_t *pre = NULL;
486 http_header_options_t *cur = NULL;
488 int wanted_str_len = 0;
489 char *wanted_str = NULL;
490 char *wanted_str_start = NULL;
491 char *wanted_str_end = NULL;
492 char *cur_pos = NULL;
499 /* Do Not use strtok(). It's not thread safe. */
500 // DA_SECURE_LOGD("org_str = %s", org_str);
505 wanted_str_start = cur_pos;
506 wanted_str_end = strchr(cur_pos, ';');
507 if (wanted_str_end) {
508 cur_pos = wanted_str_end + 1;
510 wanted_str_end = org_str + strlen(org_str);
513 wanted_str_len = wanted_str_end - wanted_str_start;
514 wanted_str = (char *)calloc(1, wanted_str_len + 1);
516 DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
517 ret = DA_ERR_FAIL_TO_MEMALLOC;
520 strncpy(wanted_str, wanted_str_start, wanted_str_len);
522 // DA_SECURE_LOGD("wanted_str = [%s]", wanted_str);
523 cur = __parsing_N_create_option_str(wanted_str);
536 if (ret != DA_RESULT_OK)
537 __http_header_destroy_all_option(&head);
541 void __parsing_raw_value(http_header_t *http_header_field)
543 char *raw_value = NULL;
544 char *option_str_start = NULL;
545 char *trimed_value = NULL;
546 int trimed_value_len = 0;
547 char *trimed_value_start = NULL;
548 char *trimed_value_end = NULL;
550 raw_value = http_header_field->raw_value;
551 // DA_SECURE_LOGD("raw_value = [%s]", raw_value);
556 trimed_value_start = raw_value;
557 trimed_value_end = strchr(raw_value, ';');
558 if (!trimed_value_end) {
560 http_header_field->value = strdup(raw_value);
561 http_header_field->options = NULL;
567 trimed_value_len = trimed_value_end - trimed_value_start;
568 trimed_value = (char *)calloc(1, trimed_value_len + 1);
570 DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
573 strncpy(trimed_value, trimed_value_start, trimed_value_len);
574 http_header_field->value = trimed_value;
576 // for option parsing
577 option_str_start = trimed_value_end + 1;
578 http_header_field->options = __parsing_options(option_str_start);
581 http_header_options_t *cur = NULL;
582 cur = http_header_field->options;
584 // DA_SECURE_LOGD("field = [%s], value = [%s]", cur->field, cur->value);
589 da_bool_t __get_http_header_option_for_field(
590 http_header_options_t *header_option, const char *in_field,
593 http_header_options_t *cur = NULL;
597 if (!header_option) {
598 DA_LOGE("input header_option is NULL.");
605 if (!strncasecmp(cur->field, in_field, strlen(cur->field)) &&
607 DA_SECURE_LOGD("[%s][%s]", cur->field, cur->value);
608 *out_value = cur->value;
618 da_bool_t __get_http_header_for_field(http_msg_response_t *http_msg_response,
619 const char *in_field, http_header_t **out_header)
621 http_msg_iter_t http_msg_iter;
622 http_header_t *header = NULL;
627 http_msg_response_get_iter(http_msg_response, &http_msg_iter);
628 while (http_msg_get_header_with_iter(&http_msg_iter, &field, &header)) {
629 if (field && header && !strncasecmp(field, in_field, strlen(field))) {
630 //DA_SECURE_LOGD("[%s][%s]", field, header->value);
631 *out_header = header;
639 da_bool_t __get_http_req_header_for_field(http_msg_request_t *http_msg_request,
640 const char *in_field, http_header_t **out_header)
642 http_msg_iter_t http_msg_iter;
643 http_header_t *header = NULL;
648 http_msg_request_get_iter(http_msg_request, &http_msg_iter);
649 while (http_msg_get_header_with_iter(&http_msg_iter, &field, &header)) {
650 if (field && header && !strncasecmp(field, in_field, strlen(field))) {
651 //DA_SECURE_LOGD("[%s][%s]", field, header->value);
652 *out_header = header;
660 void __exchange_header_value(http_header_t *header, const char *in_raw_value)
664 if (!header || !in_raw_value)
667 __http_header_destroy_all_option(&(header->options));
671 header->value = DA_NULL;
673 if (header->raw_value)
674 free(header->raw_value);
675 header->raw_value = strdup(in_raw_value);
677 __parsing_raw_value(header);
680 da_bool_t http_msg_response_get_content_type(
681 http_msg_response_t *http_msg_response, char **out_type)
683 da_bool_t b_ret = DA_FALSE;
684 http_header_t *header = NULL;
688 b_ret = __get_http_header_for_field(http_msg_response,
689 HTTP_FIELD_CONTENT_TYPE, &header);
691 DA_LOGV("no Content-Type");
695 *out_type = strdup(header->value);
700 void http_msg_response_set_content_type(http_msg_response_t *http_msg_response,
703 da_bool_t b_ret = DA_FALSE;
704 http_header_t *header = NULL;
708 if (!http_msg_response || !in_type)
711 b_ret = __get_http_header_for_field(http_msg_response,
712 HTTP_FIELD_CONTENT_TYPE, &header);
714 if (header->raw_value && (!strncmp(header->raw_value, in_type,
715 strlen(header->raw_value))))
718 DA_SECURE_LOGD("exchange Content-Type to [%s] from [%s]", in_type, header->value);
719 __exchange_header_value(header, in_type);
721 __http_header_add_field(&(http_msg_response->head),
722 HTTP_FIELD_CONTENT_TYPE, in_type, WITH_PARSING_OPTION);
726 da_bool_t http_msg_response_get_content_length(
727 http_msg_response_t *http_msg_response, da_size_t *out_length)
729 da_bool_t b_ret = DA_FALSE;
730 http_header_t *header = NULL;
734 b_ret = __get_http_header_for_field(http_msg_response,
735 HTTP_FIELD_CONTENT_LENGTH, &header);
737 DA_LOGV( "no Content-Length");
742 *out_length = atoll(header->value);
747 da_bool_t http_msg_response_get_content_disposition(
748 http_msg_response_t *http_msg_response, http_msg_t *http_msg, char **out_disposition,
749 char **out_file_name)
751 da_bool_t b_ret = DA_FALSE;
752 http_header_t *header = NULL;
753 char *file_name = NULL;
754 char *wanted_str = NULL;
755 char *wanted_str_start = NULL;
756 char *wanted_str_end = NULL;
757 char *decoded_str = NULL;
758 int wanted_str_len = 0;
762 b_ret = __get_http_header_for_field(http_msg_response,
763 HTTP_FIELD_CONTENT_DISPOSITION, &header);
765 DA_LOGV( "no Content-Disposition");
769 *out_disposition = strdup(header->value);
773 b_ret = __get_http_header_option_for_field(header->options, "filename",
776 DA_LOGV( "no option");
780 // eliminate double quotation mark if it exists on derived value
781 wanted_str_start = strchr(file_name, '"');
782 if (!wanted_str_start) {
783 *out_file_name = strdup(file_name);
786 // DA_SECURE_LOGD("wanted_str_start = [%s]", wanted_str_start);
788 wanted_str_end = strchr(wanted_str_start, '"');
789 if (wanted_str_end) {
790 wanted_str_len = wanted_str_end - wanted_str_start;
791 wanted_str = (char*)calloc(1, wanted_str_len + 1);
793 DA_LOGE("DA_ERR_FAIL_TO_MEMALLOC");
796 strncpy(wanted_str, wanted_str_start, wanted_str_len);
798 b_ret = is_base64_encoded_word(wanted_str);
800 DA_LOGV("It's base64 encoded-word string");
801 if (DA_RESULT_OK == decode_base64_encoded_str(
802 wanted_str, &decoded_str)) {
803 DA_SECURE_LOGD("base64 decoded str = [%s]", decoded_str);
805 wanted_str = decoded_str;
808 DA_LOGV("Fail to base64 decode. Just use un-decoded string.");
811 DA_LOGV("It's NOT base64 encoded-word string");
815 decoded_str = curl_easy_unescape(http_msg->curl, wanted_str, wanted_str_len, NULL);
818 CURL* handle = curl_easy_init();
819 decoded_str = curl_easy_unescape(handle, wanted_str, wanted_str_len, NULL);
820 curl_easy_cleanup(handle);
823 /* If it is url encoded string */
826 DA_SECURE_LOGD("Url decoded str = [%s]", decoded_str);
827 file_name = (char*)calloc(1, strlen(decoded_str) + 1);
828 strncpy(file_name, decoded_str, strlen(decoded_str));
830 NULL_CHECK_AND_FREE(wanted_str);
831 curl_free(decoded_str);
834 *out_file_name = file_name;
838 DA_LOGE("Fail to url decode.");
839 NULL_CHECK_AND_FREE(wanted_str);
840 *out_file_name = NULL;
844 DA_LOGE("Not matched \" !");
850 da_bool_t http_msg_response_get_ETag(http_msg_response_t *http_msg_response,
853 da_bool_t b_ret = DA_FALSE;
854 http_header_t *header = NULL;
858 b_ret = __get_http_header_for_field(http_msg_response, HTTP_FIELD_ETAG,
865 *out_value = strdup(header->value);
871 da_bool_t http_msg_response_get_RAF_mode(http_msg_response_t *http_msg_response,
874 da_bool_t b_ret = DA_FALSE;
875 http_header_t *header = NULL;
879 b_ret = __get_http_header_for_field(http_msg_response, HTTP_FIELD_RAF_MODE,
882 DA_LOGV( "no RAF mode");
886 *out_value = strdup(header->value);
892 da_bool_t http_msg_response_get_date(http_msg_response_t *http_msg_response,
895 da_bool_t b_ret = DA_FALSE;
896 http_header_t *header = NULL;
900 b_ret = __get_http_header_for_field(http_msg_response,
901 HTTP_FIELD_DATA, &header);
907 *out_value = strdup(header->value);
912 da_bool_t http_msg_response_get_location(http_msg_response_t *http_msg_response,
915 da_bool_t b_ret = DA_FALSE;
916 http_header_t *header = NULL;
920 b_ret = __get_http_header_for_field(http_msg_response,
921 HTTP_FIELD_LOCATION, &header);
923 DA_LOGV( "no Location");
927 *out_value = strdup(header->value);
932 char *__stristr(const char *long_str, const char *find_str)
937 char *ret_ptr = NULL;
938 char *org_ptr = NULL;
939 char *look_ptr = NULL;
941 if (long_str == NULL || find_str == NULL) {
942 DA_LOGE("INVALID ARGUMENT");
946 length_long = strlen(long_str);
947 length_find = strlen(find_str);
949 org_ptr = (char*)calloc(1, length_long + 1);
951 if (org_ptr == NULL) {
952 DA_LOGE("INVALID ARGUMENT");
956 look_ptr = (char*)calloc(1, length_find + 1);
958 if (look_ptr == NULL) {
959 DA_LOGE("INVALID ARGUMENT");
964 while (i < length_long) {
965 if (isalpha(long_str[i]) != 0) {
966 if (isupper(long_str[i]) != 0) {
967 org_ptr[i] = long_str[i];
969 org_ptr[i] = toupper(long_str[i]);
972 org_ptr[i] = long_str[i];
979 while (i < length_find) {
980 if (isalpha(find_str[i]) != 0) {
981 if (isupper(find_str[i]) != 0) {
982 look_ptr[i] = find_str[i];
984 look_ptr[i] = toupper(find_str[i]);
987 look_ptr[i] = find_str[i];
992 ret_ptr = strstr(org_ptr, look_ptr);
999 i = ret_ptr - org_ptr;
1005 return (char*)(long_str + i);
1008 /* This is not used. But it can be needed if there is no http header parser at http library.*/
1009 da_bool_t extract_attribute_from_header(
1011 const char *szFindStr,
1014 char *pValuePos = NULL;
1018 int need_to_end_quataion_mark = 0;
1020 if (szHeadStr == DA_NULL || szFindStr == DA_NULL) {
1021 DA_LOGE("INVALID ARGUMENT");
1024 if (strlen(szHeadStr) <= 0 || strlen(szFindStr) <= 0) {
1025 DA_LOGE("INVALID ARGUMENT");;
1029 if (ppRtnValue == NULL) {
1033 pValuePos = __stristr(szHeadStr, (char*)szFindStr);
1034 if (pValuePos == NULL) {
1039 index = strlen(szFindStr);
1041 while (pValuePos[index] != ':' && pValuePos[index] != '=') {
1044 if (pValuePos[index] == '\0') {
1052 while (pValuePos[index] == ' ') {
1056 /* jump quatation mark */
1057 while (pValuePos[index] == '"') {
1058 need_to_end_quataion_mark = 1;
1064 /* Find the end of data. */
1065 if (0 == strncasecmp(szFindStr, HTTP_FIELD_LOCATION,
1066 strlen(HTTP_FIELD_LOCATION)))//terminate character list does not contain ';' in case of URI
1068 while (DA_FALSE == IS_URI_TERMINATING_CHAR(pValuePos[index])) {
1071 } else if (need_to_end_quataion_mark) {
1072 while (DA_FALSE == IS_TERMINATING_CHAR_EX(pValuePos[index])) {
1076 while (DA_FALSE == IS_TERMINATING_CHAR(pValuePos[index])) {
1081 strLen = index - startPos;
1084 DA_LOGE(" strLen is < 1");
1088 *ppRtnValue = (char*)calloc(1, sizeof(char) * (strLen + 1));
1090 if (*ppRtnValue == NULL) {
1091 DA_LOGE(" *ppRtnValue is NULL");
1095 strncpy(*ppRtnValue, pValuePos + startPos, strLen);
1096 *(*ppRtnValue + strLen) = '\0';
1107 da_bool_t http_msg_request_get_if_range(http_msg_request_t *http_msg_request,
1110 da_bool_t b_ret = DA_FALSE;
1111 http_header_t *header = NULL;
1115 b_ret = __get_http_req_header_for_field(http_msg_request, HTTP_FIELD_IF_RANGE,
1118 DA_LOGV( "no If Range");
1122 *out_value = strdup(header->value);
1127 da_bool_t http_msg_request_get_range(http_msg_request_t *http_msg_request,
1130 da_bool_t b_ret = DA_FALSE;
1131 http_header_t *header = NULL;
1135 b_ret = __get_http_req_header_for_field(http_msg_request, HTTP_FIELD_RANGE,
1138 DA_LOGV( "no Range");
1142 *out_value = strdup(header->value);