merge with master
[platform/framework/web/download-provider.git] / agent / download-agent-http-misc.c
1 /*
2  * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "download-agent-http-misc.h"
18 #include "download-agent-debug.h"
19 #include "download-agent-dl-mgr.h"
20 #include "download-agent-plugin-conf.h"
21 #include "download-agent-client-mgr.h"
22
23 #define DEFAULT_HTTP_ACCEPT_HEADERS \
24                 "Accept-Language: en\r\n" \
25                 "Accept-Charset: utf-8\r\n" \
26
27
28 char *get_user_agent()
29 {
30         char *uagent_str = DA_NULL;
31
32         DA_LOG_FUNC_START(Default);
33
34         uagent_str = get_client_user_agent_string();
35         if (!uagent_str) {
36                 da_result_t ret = DA_RESULT_OK;
37                 ret = get_user_agent_string(&uagent_str);
38                 if (ret != DA_RESULT_OK)
39                         return NULL;
40         }
41         return uagent_str;
42 }
43
44 da_bool_t is_supporting_protocol(const char *protocol)
45 {
46         if((protocol == NULL) || (1 > strlen(protocol)))
47         {
48                 return DA_FALSE;
49         }
50
51         if(!strcasecmp(protocol, "http"))
52         {
53                 return DA_TRUE;
54         }
55         else if(!strcasecmp(protocol, "https"))
56         {
57                 return DA_TRUE;
58         }
59         else
60         {
61                 return DA_FALSE;
62         }
63
64 }