diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp index 20ab248a5..b85fc4300 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitURIResponse.cpp @@ -22,6 +22,7 @@ #include "WebKitPrivate.h" #include "WebKitURIResponsePrivate.h" +#include <WebCore/GUniquePtrSoup.h> #include <glib/gi18n-lib.h> #include <wtf/text/CString.h> @@ -46,7 +47,8 @@ enum { PROP_STATUS_CODE, PROP_CONTENT_LENGTH, PROP_MIME_TYPE, - PROP_SUGGESTED_FILENAME + PROP_SUGGESTED_FILENAME, + PROP_HTTP_HEADERS }; struct _WebKitURIResponsePrivate { @@ -54,6 +56,7 @@ struct _WebKitURIResponsePrivate { CString uri; CString mimeType; CString suggestedFilename; + GUniquePtr<SoupMessageHeaders> httpHeaders; }; WEBKIT_DEFINE_TYPE(WebKitURIResponse, webkit_uri_response, G_TYPE_OBJECT) @@ -78,6 +81,9 @@ static void webkitURIResponseGetProperty(GObject* object, guint propId, GValue* case PROP_SUGGESTED_FILENAME: g_value_set_string(value, webkit_uri_response_get_suggested_filename(response)); break; + case PROP_HTTP_HEADERS: + g_value_set_boxed(value, webkit_uri_response_get_http_headers(response)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); } @@ -151,6 +157,23 @@ static void webkit_uri_response_class_init(WebKitURIResponseClass* responseClass _("The suggested filename for the URI response"), 0, WEBKIT_PARAM_READABLE)); + + /** + * WebKitURIResponse:http-headers: + * + * The HTTP headers of the response, or %NULL if the response is not an HTTP response. + * + * Since: 2.6 + */ + g_object_class_install_property( + objectClass, + PROP_HTTP_HEADERS, + g_param_spec_boxed( + "http-headers", + _("HTTP Headers"), + _("The The HTTP headers of the response"), + SOUP_TYPE_MESSAGE_HEADERS, + WEBKIT_PARAM_READABLE)); } /** @@ -237,6 +260,31 @@ const gchar* webkit_uri_response_get_suggested_filename(WebKitURIResponse* respo return response->priv->suggestedFilename.data(); } +/** + * webkit_uri_response_get_http_headers: + * @response: a #WebKitURIResponse + * + * Get the HTTP headers of a #WebKitURIResponse as a #SoupMessageHeaders. + * + * Returns: (transfer none): a #SoupMessageHeaders with the HTTP headers of @response + * or %NULL if @response is not an HTTP response. + * Since: 2.6 + */ +SoupMessageHeaders* webkit_uri_response_get_http_headers(WebKitURIResponse* response) +{ + g_return_val_if_fail(WEBKIT_IS_URI_RESPONSE(response), nullptr); + + if (response->priv->httpHeaders) + return response->priv->httpHeaders.get(); + + if (!response->priv->resourceResponse.url().protocolIsInHTTPFamily()) + return nullptr; + + response->priv->httpHeaders.reset(soup_message_headers_new(SOUP_MESSAGE_HEADERS_RESPONSE)); + response->priv->resourceResponse.updateSoupMessageHeaders(response->priv->httpHeaders.get()); + return response->priv->httpHeaders.get(); +} + WebKitURIResponse* webkitURIResponseCreateForResourceResponse(const WebCore::ResourceResponse& resourceResponse) { WebKitURIResponse* uriResponse = WEBKIT_URI_RESPONSE(g_object_new(WEBKIT_TYPE_URI_RESPONSE, NULL)); |