2 Copyright (C) 2011 Samsung Electronics
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
21 #include "ewk_network.h"
24 #include "ewk_logging.h"
27 #include "ResourceHandle.h"
28 #include <libsoup/soup.h>
31 #include <wtf/text/CString.h>
34 * Cancel pending request in network session.
35 * The pending network requests cannot be sent when
36 * network device is changed. New socket need to be opened.
38 void ewk_network_session_requests_cancel(void)
40 #if ENABLE(TIZEN_SESSION_REQUEST_CANCEL)
42 SoupSession* session = WebCore::ResourceHandle::defaultSession();
43 soup_session_abort(session);
45 EINA_SAFETY_ON_TRUE_RETURN(1);
46 #endif // ENABLE(TIZEN_SESSION_RESET)
48 LOG_ERROR("TIZEN_SESSION_RESET is disabled. \n");
53 * Sets the given proxy URI to network backend.
57 void ewk_network_proxy_uri_set(const char* proxy)
59 #if ENABLE(TIZEN_SET_PROXY)
60 SoupSession* session = WebCore::ResourceHandle::defaultSession();
62 if (!proxy || (strstr(proxy, "0.0.0.0") != NULL)) {
63 ERR("no proxy uri. remove proxy feature in soup.");
65 g_object_set(session, SOUP_SESSION_PROXY_URI, NULL, NULL);
66 soup_session_remove_feature_by_type(session, SOUP_TYPE_PROXY_RESOLVER);
68 WTF::String proxyValue;
69 proxyValue = WTF::String(proxy);
71 // improve proxy string
72 if (proxyValue.length() > 0) {
73 if (proxyValue.startsWith("http://", false) == false)
74 proxyValue.insert("http://", 0);
77 SoupURI* uri = soup_uri_new(proxyValue.utf8().data());
78 EINA_SAFETY_ON_NULL_RETURN(uri);
80 g_object_set(session, SOUP_SESSION_PROXY_URI, uri, NULL);
83 #else // ENABLE(TIZEN_SET_PROXY)
85 SoupURI* uri = soup_uri_new(proxy);
86 EINA_SAFETY_ON_NULL_RETURN(uri);
88 g_object_set(session, SOUP_SESSION_PROXY_URI, uri, NULL);
91 EINA_SAFETY_ON_TRUE_RETURN(1);
96 void ewk_network_http_request_append(const char* name, const char* value)
98 #if ENABLE(TIZEN_HTTP_HEADER_REQUEST_APPEND)
100 WebCore::ResourceHandle::appendHttpRequestHeader(name, value);
102 EINA_SAFETY_ON_TRUE_RETURN(1);