1231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block/* 2231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Copyright (C) 2007, 2008 Holger Hans Peter Freyther 3231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Copyright (C) 2009 Gustavo Noronha Silva 4231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Copyright (C) 2009 Collabora Ltd. 5231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 6231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * This library is free software; you can redistribute it and/or 7231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * modify it under the terms of the GNU Library General Public 8231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * License as published by the Free Software Foundation; either 9231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * version 2 of the License, or (at your option) any later version. 10231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 11231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * This library is distributed in the hope that it will be useful, 12231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * but WITHOUT ANY WARRANTY; without even the implied warranty of 13231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Library General Public License for more details. 15231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 16231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * You should have received a copy of the GNU Library General Public License 17231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * along with this library; see the file COPYING.LIB. If not, write to 18231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 19231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Boston, MA 02110-1301, USA. 20231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block */ 21231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 22231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include "config.h" 23231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include "webkitnetworkresponse.h" 24231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 2521939df44de1705786c545cd1bf519d47250322dBen Murdoch#include "GRefPtr.h" 26231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include "ResourceResponse.h" 27cad810f21b803229eb11403f9209855525a25d57Steve Block#include "webkitglobalsprivate.h" 28231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#include <glib/gi18n-lib.h> 29cad810f21b803229eb11403f9209855525a25d57Steve Block#include <wtf/text/CString.h> 30231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 31231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block/** 32231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * SECTION:webkitnetworkresponse 33231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * @short_description: the response given to a network request 34231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * @see_also: #WebKitNetworkRequest 35231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 36231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * This class represents the network related aspects of a navigation 37231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * response. 38231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 39231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Since: 1.1.14 40231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block */ 41231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 42231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve BlockG_DEFINE_TYPE(WebKitNetworkResponse, webkit_network_response, G_TYPE_OBJECT); 43231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 44231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockstruct _WebKitNetworkResponsePrivate { 45231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block gchar* uri; 46231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block SoupMessage* message; 47231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block}; 48231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 49231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block#define WEBKIT_NETWORK_RESPONSE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_NETWORK_RESPONSE, WebKitNetworkResponsePrivate)) 50231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 51231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockenum { 52231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block PROP_0, 53231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 54231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block PROP_URI, 55231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block PROP_MESSAGE, 56231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block}; 57231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 58231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockstatic void webkit_network_response_dispose(GObject* object) 59231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 60231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object); 61231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponsePrivate* priv = response->priv; 62231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 63231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block if (priv->message) { 64231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_object_unref(priv->message); 65231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block priv->message = NULL; 66231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block } 67231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 68231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block G_OBJECT_CLASS(webkit_network_response_parent_class)->dispose(object); 69231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 70231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 71231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockstatic void webkit_network_response_finalize(GObject* object) 72231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 73231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object); 74231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponsePrivate* priv = response->priv; 75231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 76231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_free(priv->uri); 77231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 78231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block G_OBJECT_CLASS(webkit_network_response_parent_class)->finalize(object); 79231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 80231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 81231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockstatic void webkit_network_response_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* pspec) 82231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 83231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object); 84231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 85231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block switch(propertyID) { 86231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block case PROP_URI: 87231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_value_set_string(value, webkit_network_response_get_uri(response)); 88231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block break; 89231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block case PROP_MESSAGE: 90231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_value_set_object(value, webkit_network_response_get_message(response)); 91231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block break; 92231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block default: 93231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec); 94231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block } 95231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 96231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 97231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockstatic void webkit_network_response_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* pspec) 98231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 99231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponse* response = WEBKIT_NETWORK_RESPONSE(object); 100231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponsePrivate* priv = response->priv; 101231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 102231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block switch(propertyID) { 103231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block case PROP_URI: 104231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block webkit_network_response_set_uri(response, g_value_get_string(value)); 105231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block break; 106231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block case PROP_MESSAGE: 107231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block priv->message = SOUP_MESSAGE(g_value_dup_object(value)); 108231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block break; 109231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block default: 110231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec); 111231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block } 112231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 113231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 114231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockstatic void webkit_network_response_class_init(WebKitNetworkResponseClass* responseClass) 115231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 116231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block GObjectClass* objectClass = G_OBJECT_CLASS(responseClass); 117231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 118231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block objectClass->dispose = webkit_network_response_dispose; 119231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block objectClass->finalize = webkit_network_response_finalize; 120231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block objectClass->get_property = webkit_network_response_get_property; 121231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block objectClass->set_property = webkit_network_response_set_property; 122231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 123cad810f21b803229eb11403f9209855525a25d57Steve Block webkitInit(); 124231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 125231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block /** 126231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * WebKitNetworkResponse:uri: 127231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 128231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * The URI to which the response will be made. 129231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 130231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Since: 1.1.14 131231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block */ 132231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_object_class_install_property(objectClass, PROP_URI, 133231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_param_spec_string("uri", 134231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block _("URI"), 135231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block _("The URI to which the response will be made."), 136231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block NULL, 137231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block (GParamFlags)(WEBKIT_PARAM_READWRITE))); 138231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 139231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block /** 140231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * WebKitNetworkResponse:message: 141231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 142231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * The #SoupMessage that backs the response. 143231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 144231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Since: 1.1.14 145231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block */ 146231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_object_class_install_property(objectClass, PROP_MESSAGE, 147231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_param_spec_object("message", 148231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block _("Message"), 149231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block _("The SoupMessage that backs the response."), 150231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block SOUP_TYPE_MESSAGE, 151231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block (GParamFlags)(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY))); 152231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 153231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_type_class_add_private(responseClass, sizeof(WebKitNetworkResponsePrivate)); 154231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 155231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 156231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockstatic void webkit_network_response_init(WebKitNetworkResponse* response) 157231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 158231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block response->priv = WEBKIT_NETWORK_RESPONSE_GET_PRIVATE(response); 159231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 160231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 161231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block/** 162231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * webkit_network_response_new: 163231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * @uri: an URI 164231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 165231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Creates a new #WebKitNetworkResponse initialized with an URI. 166231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 167231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Returns: a new #WebKitNetworkResponse, or %NULL if the URI is 168231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * invalid. 169231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 170231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Since: 1.1.14 171231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block */ 172231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve BlockWebKitNetworkResponse* webkit_network_response_new(const gchar* uri) 173231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 174231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_return_val_if_fail(uri, NULL); 175231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 176231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", uri, NULL)); 177231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 178231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 179231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block/** 180231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * webkit_network_response_set_uri: 181231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * @response: a #WebKitNetworkResponse 182231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * @uri: an URI 183231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 184231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Sets the URI held and used by the given response. When the response 185231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * has an associated #SoupMessage, its URI will also be set by this 186231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * call. 187231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 188231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Since: 1.1.14 189231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block */ 190231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Blockvoid webkit_network_response_set_uri(WebKitNetworkResponse* response, const gchar* uri) 191231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 192231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_return_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response)); 193231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_return_if_fail(uri); 194231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 195231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponsePrivate* priv = response->priv; 196231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 197231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block if (priv->uri) 198231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_free(priv->uri); 199231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block priv->uri = g_strdup(uri); 200231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 201231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block if (!priv->message) 202231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block return; 203231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 204231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block SoupURI* soupURI = soup_uri_new(uri); 205231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_return_if_fail(soupURI); 206231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 207231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block soup_message_set_uri(priv->message, soupURI); 208231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block soup_uri_free(soupURI); 209231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 210231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 211231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block/** 212231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * webkit_network_response_get_uri: 213231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * @response: a #WebKitNetworkResponse 214231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 215231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Returns: the uri of the #WebKitNetworkResponse 216231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 217231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Since: 1.1.14 218231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block */ 219231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve BlockG_CONST_RETURN gchar* webkit_network_response_get_uri(WebKitNetworkResponse* response) 220231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 221231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_return_val_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response), NULL); 222231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 223231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponsePrivate* priv = response->priv; 224231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 225231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block if (priv->uri) 226231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block return priv->uri; 227231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 228231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block SoupURI* soupURI = soup_message_get_uri(priv->message); 229231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block priv->uri = soup_uri_to_string(soupURI, FALSE); 230231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block return priv->uri; 231231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 232231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 233231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block/** 234bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen * webkit_network_response_get_message: 235231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * @response: a #WebKitNetworkResponse 236231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 237231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Obtains the #SoupMessage that represents the given response. Notice 238231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * that only the response side of the HTTP conversation is 239231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * represented. 240231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * 241bec39347bb3bb5bf1187ccaf471d26247f28b585Kristian Monsen * Returns: (transfer none): the #SoupMessage 242231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block * Since: 1.1.14 243231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block */ 244231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve BlockSoupMessage* webkit_network_response_get_message(WebKitNetworkResponse* response) 245231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block{ 246231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block g_return_val_if_fail(WEBKIT_IS_NETWORK_RESPONSE(response), NULL); 247231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 248231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block WebKitNetworkResponsePrivate* priv = response->priv; 249231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block 250231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block return priv->message; 251231d4e3152a9c27a73b6ac7badbe6be673aa3ddfSteve Block} 252f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 253f05b935882198ccf7d81675736e3aeb089c5113aBen Murdochnamespace WebKit { 254f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 255f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochWebCore::ResourceResponse core(WebKitNetworkResponse* response) 256f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 257f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch SoupMessage* soupMessage = webkit_network_response_get_message(response); 258f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (soupMessage) 259f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return WebCore::ResourceResponse(soupMessage); 260f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 261f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return WebCore::ResourceResponse(); 262f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 263f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 264f05b935882198ccf7d81675736e3aeb089c5113aBen MurdochWebKitNetworkResponse* kitNew(const WebCore::ResourceResponse& resourceResponse) 265f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch{ 266cad810f21b803229eb11403f9209855525a25d57Steve Block GRefPtr<SoupMessage> soupMessage(adoptGRef(resourceResponse.toSoupMessage())); 267f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch if (soupMessage) 268f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "message", soupMessage.get(), NULL)); 269f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 270f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch return WEBKIT_NETWORK_RESPONSE(g_object_new(WEBKIT_TYPE_NETWORK_RESPONSE, "uri", resourceResponse.url().string().utf8().data(), NULL)); 271f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 272f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch 273f05b935882198ccf7d81675736e3aeb089c5113aBen Murdoch} 274