Title: [285155] trunk
Revision
285155
Author
commit-qu...@webkit.org
Date
2021-11-02 01:47:27 -0700 (Tue, 02 Nov 2021)

Log Message

[GTK][WPE] Support setting status code and getting HTTP method in custom URI scheme handlers
https://bugs.webkit.org/show_bug.cgi?id=231880

Patch by Zixing Liu <liushuyu...@gmail.com> on 2021-11-02
Reviewed by Carlos Garcia Campos.

Source/WebKit:

* SourcesGTK.txt: Added WebKitURISchemeResponse.cpp
* SourcesWPE.txt: Added WebKitURISchemeResponse.cpp
* UIProcess/API/glib/WebKitURISchemeRequest.cpp:
(webkit_uri_scheme_request_get_http_method): Added new API function
(webkit_uri_request_finish_with_response): Added new API function
* UIProcess/API/glib/WebKitURISchemeRequestPrivate.h:  Added.
* UIProcess/API/glib/WebKitURISchemeResponse.cpp: Added.
(webkit_uri_scheme_response_class_init): Added init function for the new type
(webkit_uri_scheme_response_new): Added new API function
(webkit_uri_scheme_response_set_status): Added new API function
(webkit_uri_scheme_response_set_content_type): Added new API function
* UIProcess/API/glib/WebKitURISchemeResponsePrivate.h: Copied from Source/WebKit/UIProcess/API/glib/WebKitURISchemeRequestPrivate.h.
* UIProcess/API/gtk/WebKitAutocleanups.h: Register clean-up function for WebkitURISchemeResponse
* UIProcess/API/gtk/WebKitURISchemeRequest.h: Added function prototype for
webkit_uri_scheme_request_get_http_method
* UIProcess/API/gtk/WebKitURISchemeResponse.h: Added.
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Added new symbols and new types
* UIProcess/API/gtk/webkit2.h: Include a new header: WebKitURISchemeResponse.h
* UIProcess/API/wpe/WebKitURISchemeRequest.h: Added function prototype for
webkit_uri_scheme_request_get_http_method
* UIProcess/API/gtk/WebKitURISchemeResponse.h: Added.
* UIProcess/API/wpe/webkit.h: Include a new header: WebKitURISchemeResponse.h
* UIProcess/API/wpe/docs/wpe-1.0-sections.txt: Added new symbols and new types

Tools:

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp:
(testWebContextURIScheme): Added tests to test new public APIs for WebKitGtk

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (285154 => 285155)


--- trunk/Source/WebKit/ChangeLog	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/ChangeLog	2021-11-02 08:47:27 UTC (rev 285155)
@@ -1,3 +1,34 @@
+2021-11-02  Zixing Liu  <liushuyu...@gmail.com>
+
+        [GTK][WPE] Support setting status code and getting HTTP method in custom URI scheme handlers
+        https://bugs.webkit.org/show_bug.cgi?id=231880
+
+        Reviewed by Carlos Garcia Campos.
+
+        * SourcesGTK.txt: Added WebKitURISchemeResponse.cpp
+        * SourcesWPE.txt: Added WebKitURISchemeResponse.cpp
+        * UIProcess/API/glib/WebKitURISchemeRequest.cpp:
+        (webkit_uri_scheme_request_get_http_method): Added new API function
+        (webkit_uri_request_finish_with_response): Added new API function
+        * UIProcess/API/glib/WebKitURISchemeRequestPrivate.h:  Added.
+        * UIProcess/API/glib/WebKitURISchemeResponse.cpp: Added.
+        (webkit_uri_scheme_response_class_init): Added init function for the new type
+        (webkit_uri_scheme_response_new): Added new API function
+        (webkit_uri_scheme_response_set_status): Added new API function
+        (webkit_uri_scheme_response_set_content_type): Added new API function
+        * UIProcess/API/glib/WebKitURISchemeResponsePrivate.h: Copied from Source/WebKit/UIProcess/API/glib/WebKitURISchemeRequestPrivate.h.
+        * UIProcess/API/gtk/WebKitAutocleanups.h: Register clean-up function for WebkitURISchemeResponse
+        * UIProcess/API/gtk/WebKitURISchemeRequest.h: Added function prototype for 
+        webkit_uri_scheme_request_get_http_method
+        * UIProcess/API/gtk/WebKitURISchemeResponse.h: Added.
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Added new symbols and new types
+        * UIProcess/API/gtk/webkit2.h: Include a new header: WebKitURISchemeResponse.h
+        * UIProcess/API/wpe/WebKitURISchemeRequest.h: Added function prototype for 
+        webkit_uri_scheme_request_get_http_method
+        * UIProcess/API/gtk/WebKitURISchemeResponse.h: Added.
+        * UIProcess/API/wpe/webkit.h: Include a new header: WebKitURISchemeResponse.h
+        * UIProcess/API/wpe/docs/wpe-1.0-sections.txt: Added new symbols and new types
+
 2021-11-01  Michael[tm] Smith  <m...@w3.org>
 
         [WebInspector][CORS] Show HTTP status code in CORS messages.

Modified: trunk/Source/WebKit/PlatformGTK.cmake (285154 => 285155)


--- trunk/Source/WebKit/PlatformGTK.cmake	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/PlatformGTK.cmake	2021-11-02 08:47:27 UTC (rev 285155)
@@ -146,6 +146,7 @@
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitURIRequest.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitURIResponse.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitURISchemeRequest.h
+    ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitURISchemeResponse.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitURIUtilities.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitUserContent.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitUserContentFilterStore.h

Modified: trunk/Source/WebKit/PlatformWPE.cmake (285154 => 285155)


--- trunk/Source/WebKit/PlatformWPE.cmake	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/PlatformWPE.cmake	2021-11-02 08:47:27 UTC (rev 285155)
@@ -176,6 +176,7 @@
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitURIRequest.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitURIResponse.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitURISchemeRequest.h
+    ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitURISchemeResponse.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitURIUtilities.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitUserContent.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitUserContentFilterStore.h

Modified: trunk/Source/WebKit/SourcesGTK.txt (285154 => 285155)


--- trunk/Source/WebKit/SourcesGTK.txt	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/SourcesGTK.txt	2021-11-02 08:47:27 UTC (rev 285155)
@@ -173,6 +173,7 @@
 UIProcess/API/glib/WebKitSettings.cpp @no-unify
 UIProcess/API/glib/WebKitUIClient.cpp @no-unify
 UIProcess/API/glib/WebKitURISchemeRequest.cpp @no-unify
+UIProcess/API/glib/WebKitURISchemeResponse.cpp @no-unify
 UIProcess/API/glib/WebKitURIUtilities.cpp @no-unify
 UIProcess/API/glib/WebKitUserContent.cpp @no-unify
 UIProcess/API/glib/WebKitUserContentFilterStore.cpp @no-unify

Modified: trunk/Source/WebKit/SourcesWPE.txt (285154 => 285155)


--- trunk/Source/WebKit/SourcesWPE.txt	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/SourcesWPE.txt	2021-11-02 08:47:27 UTC (rev 285155)
@@ -164,6 +164,7 @@
 UIProcess/API/glib/WebKitSettings.cpp @no-unify
 UIProcess/API/glib/WebKitUIClient.cpp @no-unify
 UIProcess/API/glib/WebKitURISchemeRequest.cpp @no-unify
+UIProcess/API/glib/WebKitURISchemeResponse.cpp @no-unify
 UIProcess/API/glib/WebKitURIUtilities.cpp @no-unify
 UIProcess/API/glib/WebKitUserContent.cpp @no-unify
 UIProcess/API/glib/WebKitUserContentFilterStore.cpp @no-unify

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeRequest.cpp (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeRequest.cpp	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeRequest.cpp	2021-11-02 08:47:27 UTC (rev 285155)
@@ -23,6 +23,7 @@
 #include "APIData.h"
 #include "WebKitPrivate.h"
 #include "WebKitURISchemeRequestPrivate.h"
+#include "WebKitURISchemeResponsePrivate.h"
 #include "WebKitWebContextPrivate.h"
 #include "WebKitWebView.h"
 #include "WebPageProxy.h"
@@ -64,12 +65,11 @@
     CString uriScheme;
     CString uriPath;
 
-    GRefPtr<GInputStream> stream;
-    uint64_t streamLength;
+    GRefPtr<WebKitURISchemeResponse> response;
     GRefPtr<GCancellable> cancellable;
     char readBuffer[gReadBufferSize];
     uint64_t bytesRead;
-    CString contentType;
+    const char* httpMethod;
 };
 
 WEBKIT_DEFINE_TYPE(WebKitURISchemeRequest, webkit_uri_scheme_request, G_TYPE_OBJECT)
@@ -161,6 +161,26 @@
     return webkitWebContextGetWebViewForPage(request->priv->webContext, request->priv->initiatingPage.get());
 }
 
+/**
+ * webkit_uri_scheme_request_get_http_method:
+ * @request: a #WebKitURISchemeRequest
+ *
+ * Get the HTTP method of the @request
+ *
+ * Returns: the HTTP method of the @request
+ * 
+ * Since: 2.36
+ */
+const gchar* webkit_uri_scheme_request_get_http_method(WebKitURISchemeRequest* request)
+{
+    g_return_val_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request), nullptr);
+
+    if (!request->priv->httpMethod)
+        request->priv->httpMethod = g_intern_string(request->priv->task->request().httpMethod().utf8().data());
+
+    return request->priv->httpMethod;
+}
+
 static void webkitURISchemeRequestReadCallback(GInputStream* inputStream, GAsyncResult* result, WebKitURISchemeRequest* schemeRequest)
 {
     GRefPtr<WebKitURISchemeRequest> request = adoptGRef(schemeRequest);
@@ -174,14 +194,22 @@
     WebKitURISchemeRequestPrivate* priv = request->priv;
     // Need to check the stream before proceeding as it can be cancelled if finish_error
     // was previously call, which won't be detected by g_input_stream_read_finish().
-    if (!priv->stream)
+    if (!priv->response)
         return;
 
+    WebKitURISchemeResponse* resp = priv->response.get();
     if (!priv->bytesRead) {
-        ResourceResponse response(priv->task->request().url(), extractMIMETypeFromMediaType(priv->contentType.data()), priv->streamLength, emptyString());
-        response.setTextEncodingName(extractCharsetFromMediaType(priv->contentType.data()));
-        response.setHTTPStatusCode(200);
-        response.setHTTPStatusText("OK"_s);
+        CString contentType = WebKitURISchemeResponseGetContentType(resp);
+        ResourceResponse response(priv->task->request().url(), extractMIMETypeFromMediaType(contentType.data()), WebKitURISchemeResponseGetStreamLength(resp), emptyString());
+        response.setTextEncodingName(extractCharsetFromMediaType(contentType.data()));
+        const CString& statusMessage = WebKitURISchemeResponseGetStatusMessage(resp);
+        if (statusMessage.isNull()) {
+            response.setHTTPStatusCode(200);
+            response.setHTTPStatusText("OK"_s);
+        } else {
+            response.setHTTPStatusCode(WebKitURISchemeResponseGetStatusCode(resp));
+            response.setHTTPStatusText(statusMessage.data());
+        }
         if (response.mimeType().isEmpty())
             response.setMimeType(MIMETypeRegistry::mimeTypeForPath(response.url().path().toString()));
         priv->task->didReceiveResponse(response);
@@ -188,6 +216,7 @@
     }
 
     if (!bytesRead) {
+        priv->response = nullptr;
         priv->task->didComplete({ });
         return;
     }
@@ -213,13 +242,31 @@
     g_return_if_fail(G_IS_INPUT_STREAM(inputStream));
     g_return_if_fail(streamLength == -1 || streamLength >= 0);
 
-    request->priv->stream = inputStream;
-    // We use -1 in the API for consistency with soup when the content length is not known, but 0 internally.
-    request->priv->streamLength = streamLength == -1 ? 0 : streamLength;
+    GRefPtr<WebKitURISchemeResponse> response = adoptGRef(webkit_uri_scheme_response_new(inputStream, streamLength));
+    if (contentType)
+        webkit_uri_scheme_response_set_content_type(response.get(), contentType);
+
+    webkit_uri_scheme_request_finish_with_response(request, response.get());
+}
+
+/**
+ * webkit_uri_scheme_request_finish_with_response:
+ * @request: a #WebKitURISchemeRequest
+ * @response: a #WebKitURISchemeResponse
+ *
+ * Finish a #WebKitURISchemeRequest by returning a #WebKitURISchemeResponse
+ *
+ * Since: 2.36
+ */
+void webkit_uri_scheme_request_finish_with_response(WebKitURISchemeRequest* request, WebKitURISchemeResponse* response)
+{
+    g_return_if_fail(WEBKIT_IS_URI_SCHEME_REQUEST(request));
+    g_return_if_fail(WEBKIT_IS_URI_SCHEME_RESPONSE(response));
+
     request->priv->cancellable = adoptGRef(g_cancellable_new());
-    request->priv->bytesRead = 0;
-    request->priv->contentType = contentType;
-    g_input_stream_read_async(inputStream, request->priv->readBuffer, gReadBufferSize, RunLoopSourcePriority::AsyncIONetwork, request->priv->cancellable.get(),
+    request->priv->response = response;
+
+    g_input_stream_read_async(WebKitURISchemeResponseGetStream(response), request->priv->readBuffer, gReadBufferSize, RunLoopSourcePriority::AsyncIONetwork, request->priv->cancellable.get(),
         reinterpret_cast<GAsyncReadyCallback>(webkitURISchemeRequestReadCallback), g_object_ref(request));
 }
 
@@ -238,7 +285,7 @@
     g_return_if_fail(error);
 
     WebKitURISchemeRequestPrivate* priv = request->priv;
-    priv->stream = nullptr;
+    priv->response = nullptr;
     ResourceError resourceError(g_quark_to_string(error->domain), toWebCoreError(error->code), priv->task->request().url(), String::fromUTF8(error->message));
     priv->task->didComplete(resourceError);
 }

Added: trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeResponse.cpp (0 => 285155)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeResponse.cpp	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeResponse.cpp	2021-11-02 08:47:27 UTC (rev 285155)
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2021 Zixing Liu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitURISchemeResponsePrivate.h"
+
+#include "WebKitPrivate.h"
+#include <glib/gi18n-lib.h>
+#include <wtf/glib/GRefPtr.h>
+#include <wtf/glib/WTFGType.h>
+
+enum {
+    PROP_0,
+    PROP_STREAM,
+    PROP_STREAM_LENGTH,
+    N_PROPERTIES,
+};
+
+static GParamSpec* sObjProperties[N_PROPERTIES] = { nullptr, };
+
+using namespace WebKit;
+using namespace WebCore;
+
+/**
+ * SECTION: WebKitURISchemeResponse
+ * @Short_description: Represents a URI scheme response
+ * @Title: WebKitURISchemeResponse
+ *
+ * If you register a particular URI scheme in a #WebKitWebContext,
+ * using webkit_web_context_register_uri_scheme(), you have to provide
+ * a #WebKitURISchemeRequestCallback. After that, when a URI response
+ * is made with that particular scheme, your callback will be
+ * called. There you will be able to provide more response parameters
+ * when the methods and properties of a #WebKitURISchemeRequest is not
+ * enough.
+ * 
+ * When you finished setting up your #WebKitURISchemeResponse, call
+ * webkit_uri_request_finish_with_response() with it to return the response.
+ *
+ */
+
+struct _WebKitURISchemeResponsePrivate {
+    GRefPtr<GInputStream> stream;
+    uint64_t streamLength;
+
+    int statusCode { -1 };
+    CString statusMessage;
+    CString contentType;
+};
+
+WEBKIT_DEFINE_TYPE(WebKitURISchemeResponse, webkit_uri_scheme_response, G_TYPE_OBJECT)
+
+static void webkitURISchemeResponseSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
+{
+    WebKitURISchemeResponse* response = WEBKIT_URI_SCHEME_RESPONSE(object);
+
+    switch (propId) {
+    case PROP_STREAM:
+        response->priv->stream = G_INPUT_STREAM(g_value_get_object(value));
+        break;
+    case PROP_STREAM_LENGTH: {
+        gint64 streamLength = g_value_get_int64(value);
+        // We use -1 in the API for consistency with soup when the content length is not known, but 0 internally.
+        response->priv->streamLength = streamLength == -1 ? 0 : streamLength;
+        break;
+    }
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+    }
+}
+
+static void webkit_uri_scheme_response_class_init(WebKitURISchemeResponseClass* klass)
+{
+    GObjectClass* objectClass = G_OBJECT_CLASS(klass);
+    objectClass->set_property = webkitURISchemeResponseSetProperty;
+
+    /**
+     * WebKitURISchemeResponse:stream:
+     *
+     * The input stream to read from.
+     *
+     * Since: 2.36
+     */
+    sObjProperties[PROP_STREAM] = 
+        g_param_spec_object(
+            "stream",
+            _("Input stream"),
+            _("The input stream to read from."),
+            G_TYPE_INPUT_STREAM,
+            static_cast<GParamFlags>(WEBKIT_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+    /**
+     * WebKitURISchemeResponse:stream_length:
+     *
+     * The input stream length in bytes. -1 for unknown length.
+     *
+     * Since: 2.36
+     */
+    sObjProperties[PROP_STREAM_LENGTH] = 
+        g_param_spec_int64(
+            "stream-length",
+            _("Input stream length"),
+            _("The input stream length in bytes. -1 for unknown length."),
+            -1, INT64_MAX, -1,
+            static_cast<GParamFlags>(WEBKIT_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
+
+    g_object_class_install_properties(objectClass, N_PROPERTIES, sObjProperties);
+}
+
+// Private getters
+int WebKitURISchemeResponseGetStatusCode(const WebKitURISchemeResponse* response)
+{
+    return response->priv->statusCode;
+}
+
+GInputStream* WebKitURISchemeResponseGetStream(const WebKitURISchemeResponse* response)
+{
+    return response->priv->stream.get();
+}
+
+const CString& WebKitURISchemeResponseGetStatusMessage(const WebKitURISchemeResponse* response)
+{
+    return response->priv->statusMessage;
+}
+
+const CString& WebKitURISchemeResponseGetContentType(const WebKitURISchemeResponse* response)
+{
+    return response->priv->contentType;
+}
+
+uint64_t WebKitURISchemeResponseGetStreamLength(const WebKitURISchemeResponse* response)
+{
+    return response->priv->streamLength;
+}
+
+/**
+ * webkit_uri_scheme_response_new:
+ * @input_stream: a #GInputStream to read the contents of the request
+ * @stream_length: the length of the stream or -1 if not known
+ *
+ * Create a new #WebKitURISchemeResponse
+ *
+ * Returns: (transfer full): the newly created #WebKitURISchemeResponse.
+ *
+ * Since: 2.36
+ */
+WebKitURISchemeResponse* webkit_uri_scheme_response_new(GInputStream* inputStream, gint64 streamLength)
+{
+    g_return_val_if_fail(G_IS_INPUT_STREAM(inputStream), nullptr);
+    g_return_val_if_fail(streamLength == -1 || streamLength >= 0, nullptr);
+
+    return WEBKIT_URI_SCHEME_RESPONSE(g_object_new(WEBKIT_TYPE_URI_SCHEME_RESPONSE, "stream", inputStream, "stream-length", streamLength, nullptr));
+}
+
+/**
+ * webkit_uri_scheme_response_set_content_type:
+ * @response: a #WebKitURISchemeResponse
+ * @content_type: the content type of the stream
+ *
+ * Sets the content type for the @response
+ *
+ * Since: 2.36
+ */
+void webkit_uri_scheme_response_set_content_type(WebKitURISchemeResponse* response, const gchar* contentType)
+{
+    g_return_if_fail(WEBKIT_IS_URI_SCHEME_RESPONSE(response));
+
+    response->priv->contentType = contentType;
+}
+
+/**
+ * webkit_uri_scheme_response_set_status:
+ * @response: a #WebKitURISchemeResponse
+ * @status_code: the HTTP status code to be returned
+ * @reason_phrase: (allow-none): a reason phrase
+ *
+ * Sets the status code and reason phrase for the @response.
+ * If @status_code is a known value and @reason_phrase is %NULL, the @reason_phrase will be set automatically.
+ *
+ * Since: 2.36
+ */
+void webkit_uri_scheme_response_set_status(WebKitURISchemeResponse* response, guint statusCode, const gchar* statusMessage)
+{
+    g_return_if_fail(WEBKIT_IS_URI_SCHEME_RESPONSE(response));
+
+    response->priv->statusCode = static_cast<gint>(statusCode);
+    if (statusMessage)
+        response->priv->statusMessage = statusMessage;
+    else
+        response->priv->statusMessage = soup_status_get_phrase(statusCode);
+}

Added: trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeResponsePrivate.h (0 => 285155)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeResponsePrivate.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitURISchemeResponsePrivate.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2021 Zixing Liu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "WebKitURISchemeResponse.h"
+#include <wtf/text/CString.h>
+
+int WebKitURISchemeResponseGetStatusCode(const WebKitURISchemeResponse*);
+GInputStream* WebKitURISchemeResponseGetStream(const WebKitURISchemeResponse*);
+const CString& WebKitURISchemeResponseGetStatusMessage(const WebKitURISchemeResponse*);
+const CString& WebKitURISchemeResponseGetContentType(const WebKitURISchemeResponse*);
+uint64_t WebKitURISchemeResponseGetStreamLength(const WebKitURISchemeResponse*);

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -62,6 +62,7 @@
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitURIRequest, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitURIResponse, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitURISchemeRequest, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitURISchemeResponse, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserContentFilterStore, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserContentManager, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserMediaPermissionRequest, g_object_unref)

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitURISchemeRequest.h (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitURISchemeRequest.h	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitURISchemeRequest.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -27,6 +27,7 @@
 #include <glib-object.h>
 #include <webkit2/WebKitDefines.h>
 #include <webkit2/WebKitForwardDeclarations.h>
+#include <webkit2/WebKitURISchemeResponse.h>
 
 G_BEGIN_DECLS
 
@@ -71,6 +72,9 @@
 WEBKIT_API WebKitWebView *
 webkit_uri_scheme_request_get_web_view (WebKitURISchemeRequest *request);
 
+WEBKIT_API const gchar *
+webkit_uri_scheme_request_get_http_method (WebKitURISchemeRequest *request);
+
 WEBKIT_API void
 webkit_uri_scheme_request_finish       (WebKitURISchemeRequest *request,
                                         GInputStream           *stream,
@@ -78,6 +82,10 @@
                                         const gchar            *content_type);
 
 WEBKIT_API void
+webkit_uri_scheme_request_finish_with_response (WebKitURISchemeRequest  *request,
+                                                WebKitURISchemeResponse *response);
+
+WEBKIT_API void
 webkit_uri_scheme_request_finish_error (WebKitURISchemeRequest *request,
                                         GError                 *error);
 

Added: trunk/Source/WebKit/UIProcess/API/gtk/WebKitURISchemeResponse.h (0 => 285155)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitURISchemeResponse.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitURISchemeResponse.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2021 Zixing Liu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitURISchemeResponse_h
+#define WebKitURISchemeResponse_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+#include <webkit2/WebKitForwardDeclarations.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_URI_SCHEME_RESPONSE            (webkit_uri_scheme_response_get_type())
+#define WEBKIT_URI_SCHEME_RESPONSE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_URI_SCHEME_RESPONSE, WebKitURISchemeResponse))
+#define WEBKIT_IS_URI_SCHEME_RESPONSE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_URI_SCHEME_RESPONSE))
+#define WEBKIT_URI_SCHEME_RESPONSE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_URI_SCHEME_RESPONSE, WebKitURISchemeResponseClass))
+#define WEBKIT_IS_URI_SCHEME_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_URI_SCHEME_RESPONSE))
+#define WEBKIT_URI_SCHEME_RESPONSE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_URI_SCHEME_RESPONSE, WebKitURISchemeResponseClass))
+
+typedef struct _WebKitURISchemeResponse        WebKitURISchemeResponse;
+typedef struct _WebKitURISchemeResponseClass   WebKitURISchemeResponseClass;
+typedef struct _WebKitURISchemeResponsePrivate WebKitURISchemeResponsePrivate;
+
+struct _WebKitURISchemeResponse {
+    GObject parent;
+
+    WebKitURISchemeResponsePrivate *priv;
+};
+
+struct _WebKitURISchemeResponseClass {
+    GObjectClass parent_class;
+
+    void (*_webkit_reserved0) (void);
+    void (*_webkit_reserved1) (void);
+    void (*_webkit_reserved2) (void);
+    void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_uri_scheme_response_get_type           (void);
+
+WEBKIT_API WebKitURISchemeResponse *
+webkit_uri_scheme_response_new                (GInputStream            *input_stream,
+                                               gint64                   stream_length);
+
+WEBKIT_API void
+webkit_uri_scheme_response_set_status         (WebKitURISchemeResponse *response,
+                                               guint                    status_code,
+                                               const gchar             *reason_phrase);
+
+WEBKIT_API void
+webkit_uri_scheme_response_set_content_type   (WebKitURISchemeResponse *response,
+                                               const gchar             *content_type);
+
+G_END_DECLS
+
+#endif

Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2021-11-02 08:47:27 UTC (rev 285155)
@@ -1277,7 +1277,9 @@
 webkit_uri_scheme_request_get_uri
 webkit_uri_scheme_request_get_path
 webkit_uri_scheme_request_get_web_view
+webkit_uri_scheme_request_get_http_method
 webkit_uri_scheme_request_finish
+webkit_uri_scheme_request_finish_with_response
 webkit_uri_scheme_request_finish_error
 
 <SUBSECTION Standard>
@@ -1295,6 +1297,27 @@
 </SECTION>
 
 <SECTION>
+<FILE>WebKitURISchemeResponse</FILE>
+WebKitURISchemeResponse
+webkit_uri_scheme_response_new
+webkit_uri_scheme_response_set_content_type
+webkit_uri_scheme_response_set_status
+
+<SUBSECTION Standard>
+WebKitURISchemeResponseClass
+WEBKIT_TYPE_URI_SCHEME_RESPONSE
+WEBKIT_URI_SCHEME_RESPONSE
+WEBKIT_IS_URI_SCHEME_RESPONSE
+WEBKIT_URI_SCHEME_RESPONSE_CLASS
+WEBKIT_IS_URI_SCHEME_RESPONSE_CLASS
+WEBKIT_URI_SCHEME_RESPONSE_GET_CLASS
+
+<SUBSECTION Private>
+WebKitURISchemeResponsePrivate
+webkit_uri_scheme_response_get_type
+</SECTION>
+
+<SECTION>
 <FILE>WebKitVersion</FILE>
 webkit_get_major_version
 webkit_get_minor_version
@@ -1985,4 +2008,3 @@
 <SUBSECTION Standard>
 WEBKIT_TYPE_MEMORY_PRESSURE_SETTINGS
 </SECTION>
-

Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0.types (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0.types	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0.types	2021-11-02 08:47:27 UTC (rev 285155)
@@ -19,6 +19,7 @@
 webkit_mime_info_get_type
 webkit_web_inspector_get_type
 webkit_uri_scheme_request_get_type
+webkit_uri_scheme_response_get_type
 webkit_context_menu_get_type
 webkit_context_menu_item_get_type
 webkit_web_extension_get_type
@@ -42,4 +43,4 @@
 webkit_device_info_permission_request_get_type
 webkit_geolocation_manager_get_type
 webkit_geolocation_position_get_type
-webkit_pointer_lock_permission_request_get_type
\ No newline at end of file
+webkit_pointer_lock_permission_request_get_type

Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml	2021-11-02 08:47:27 UTC (rev 285155)
@@ -45,6 +45,7 @@
     <xi:include href=""
     <xi:include href=""
     <xi:include href=""
+    <xi:include href=""
     <xi:include href=""
     <xi:include href=""
     <xi:include href=""
@@ -170,5 +171,10 @@
     <xi:include href="" /></xi:include>
   </index>
 
+  <index id="api-index-2-36" role="2.36">
+    <title>Index of new symbols in 2.36</title>
+    <xi:include href="" /></xi:include>
+  </index>
+
   <xi:include href="" /></xi:include>
 </book>

Modified: trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -78,6 +78,7 @@
 #include <webkit2/WebKitURIRequest.h>
 #include <webkit2/WebKitURIResponse.h>
 #include <webkit2/WebKitURISchemeRequest.h>
+#include <webkit2/WebKitURISchemeResponse.h>
 #include <webkit2/WebKitURIUtilities.h>
 #include <webkit2/WebKitUserContent.h>
 #include <webkit2/WebKitUserContentFilterStore.h>

Modified: trunk/Source/WebKit/UIProcess/API/wpe/WebKitAutocleanups.h (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitAutocleanups.h	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitAutocleanups.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -56,6 +56,7 @@
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitURIRequest, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitURIResponse, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitURISchemeRequest, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitURISchemeResponse, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserContentFilterStore, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserContentManager, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitUserMediaPermissionRequest, g_object_unref)

Modified: trunk/Source/WebKit/UIProcess/API/wpe/WebKitURISchemeRequest.h (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitURISchemeRequest.h	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitURISchemeRequest.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -26,6 +26,7 @@
 
 #include <glib-object.h>
 #include <wpe/WebKitDefines.h>
+#include <wpe/WebKitURISchemeResponse.h>
 
 G_BEGIN_DECLS
 
@@ -72,6 +73,9 @@
 WEBKIT_API WebKitWebView *
 webkit_uri_scheme_request_get_web_view (WebKitURISchemeRequest *request);
 
+WEBKIT_API const gchar *
+webkit_uri_scheme_request_get_http_method (WebKitURISchemeRequest *request);
+
 WEBKIT_API void
 webkit_uri_scheme_request_finish       (WebKitURISchemeRequest *request,
                                         GInputStream           *stream,
@@ -79,6 +83,10 @@
                                         const gchar            *content_type);
 
 WEBKIT_API void
+webkit_uri_scheme_request_finish_with_response (WebKitURISchemeRequest  *request,
+                                                WebKitURISchemeResponse *response);
+
+WEBKIT_API void
 webkit_uri_scheme_request_finish_error (WebKitURISchemeRequest *request,
                                         GError                 *error);
 

Added: trunk/Source/WebKit/UIProcess/API/wpe/WebKitURISchemeResponse.h (0 => 285155)


--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitURISchemeResponse.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitURISchemeResponse.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2021 Zixing Liu
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <wpe/webkit.h> can be included directly."
+#endif
+
+#ifndef WebKitURISchemeResponse_h
+#define WebKitURISchemeResponse_h
+
+#include <glib-object.h>
+#include <wpe/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_URI_SCHEME_RESPONSE            (webkit_uri_scheme_response_get_type())
+#define WEBKIT_URI_SCHEME_RESPONSE(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_URI_SCHEME_RESPONSE, WebKitURISchemeResponse))
+#define WEBKIT_IS_URI_SCHEME_RESPONSE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_URI_SCHEME_RESPONSE))
+#define WEBKIT_URI_SCHEME_RESPONSE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_URI_SCHEME_RESPONSE, WebKitURISchemeResponseClass))
+#define WEBKIT_IS_URI_SCHEME_RESPONSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_URI_SCHEME_RESPONSE))
+#define WEBKIT_URI_SCHEME_RESPONSE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_URI_SCHEME_RESPONSE, WebKitURISchemeResponseClass))
+
+typedef struct _WebKitURISchemeResponse        WebKitURISchemeResponse;
+typedef struct _WebKitURISchemeResponseClass   WebKitURISchemeResponseClass;
+typedef struct _WebKitURISchemeResponsePrivate WebKitURISchemeResponsePrivate;
+
+struct _WebKitURISchemeResponse {
+    GObject parent;
+
+    WebKitURISchemeResponsePrivate *priv;
+};
+
+struct _WebKitURISchemeResponseClass {
+    GObjectClass parent_class;
+
+    void (*_webkit_reserved0) (void);
+    void (*_webkit_reserved1) (void);
+    void (*_webkit_reserved2) (void);
+    void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_uri_scheme_response_get_type           (void);
+
+WEBKIT_API WebKitURISchemeResponse *
+webkit_uri_scheme_response_new                (GInputStream            *input_stream,
+                                               gint64                   stream_length);
+
+WEBKIT_API void
+webkit_uri_scheme_response_set_status         (WebKitURISchemeResponse *response,
+                                               guint                    status_code,
+                                               const gchar             *reason_phrase);
+
+WEBKIT_API void
+webkit_uri_scheme_response_set_content_type   (WebKitURISchemeResponse *response,
+                                               const gchar             *content_type);
+
+G_END_DECLS
+
+#endif

Modified: trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt	2021-11-02 08:47:27 UTC (rev 285155)
@@ -1214,7 +1214,9 @@
 webkit_uri_scheme_request_get_uri
 webkit_uri_scheme_request_get_path
 webkit_uri_scheme_request_get_web_view
+webkit_uri_scheme_request_get_http_method
 webkit_uri_scheme_request_finish
+webkit_uri_scheme_request_finish_with_response
 webkit_uri_scheme_request_finish_error
 
 <SUBSECTION Standard>
@@ -1232,6 +1234,27 @@
 </SECTION>
 
 <SECTION>
+<FILE>WebKitURISchemeResponse</FILE>
+WebKitURISchemeResponse
+webkit_uri_scheme_response_new
+webkit_uri_scheme_response_set_content_type
+webkit_uri_scheme_response_set_status
+
+<SUBSECTION Standard>
+WebKitURISchemeResponseClass
+WEBKIT_TYPE_URI_SCHEME_RESPONSE
+WEBKIT_URI_SCHEME_RESPONSE
+WEBKIT_IS_URI_SCHEME_RESPONSE
+WEBKIT_URI_SCHEME_RESPONSE_CLASS
+WEBKIT_IS_URI_SCHEME_RESPONSE_CLASS
+WEBKIT_URI_SCHEME_RESPONSE_GET_CLASS
+
+<SUBSECTION Private>
+WebKitURISchemeResponsePrivate
+webkit_uri_scheme_response_get_type
+</SECTION>
+
+<SECTION>
 <FILE>WebKitVersion</FILE>
 webkit_get_major_version
 webkit_get_minor_version

Modified: trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-docs.sgml (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-docs.sgml	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-docs.sgml	2021-11-02 08:47:27 UTC (rev 285155)
@@ -41,6 +41,7 @@
     <xi:include href=""
     <xi:include href=""
     <xi:include href=""
+    <xi:include href=""
     <xi:include href=""
     <xi:include href=""
     <xi:include href=""
@@ -108,5 +109,10 @@
     <xi:include href="" /></xi:include>
   </index>
 
+  <index id="api-index-2-36" role="2.36">
+    <title>Index of new symbols in 2.36</title>
+    <xi:include href="" /></xi:include>
+  </index>
+
   <xi:include href="" /></xi:include>
 </book>

Modified: trunk/Source/WebKit/UIProcess/API/wpe/webkit.h (285154 => 285155)


--- trunk/Source/WebKit/UIProcess/API/wpe/webkit.h	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Source/WebKit/UIProcess/API/wpe/webkit.h	2021-11-02 08:47:27 UTC (rev 285155)
@@ -73,6 +73,7 @@
 #include <wpe/WebKitURIRequest.h>
 #include <wpe/WebKitURIResponse.h>
 #include <wpe/WebKitURISchemeRequest.h>
+#include <wpe/WebKitURISchemeResponse.h>
 #include <wpe/WebKitURIUtilities.h>
 #include <wpe/WebKitUserContent.h>
 #include <wpe/WebKitUserContentFilterStore.h>

Modified: trunk/Tools/ChangeLog (285154 => 285155)


--- trunk/Tools/ChangeLog	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Tools/ChangeLog	2021-11-02 08:47:27 UTC (rev 285155)
@@ -1,3 +1,13 @@
+2021-11-02  Zixing Liu  <liushuyu...@gmail.com>
+
+        [GTK][WPE] Support setting status code and getting HTTP method in custom URI scheme handlers
+        https://bugs.webkit.org/show_bug.cgi?id=231880
+
+        Reviewed by Carlos Garcia Campos.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp:
+        (testWebContextURIScheme): Added tests to test new public APIs for WebKitGtk
+
 2021-11-01  Fujii Hironori  <hironori.fu...@sony.com>
 
         ImageDiff.cpp(74): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t'

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp (285154 => 285155)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp	2021-11-02 06:56:01 UTC (rev 285154)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitWebContext.cpp	2021-11-02 08:47:27 UTC (rev 285155)
@@ -95,10 +95,11 @@
         {
         }
 
-        URISchemeHandler(const char* reply, int replyLength, const char* mimeType)
+        URISchemeHandler(const char* reply, int replyLength, const char* mimeType, int statusCode = 200)
             : reply(reply)
             , replyLength(replyLength)
             , mimeType(mimeType)
+            , statusCode(statusCode)
         {
         }
 
@@ -105,6 +106,7 @@
         CString reply;
         int replyLength;
         CString mimeType;
+        int statusCode;
     };
 
     static void uriSchemeRequestCallback(WebKitURISchemeRequest* request, gpointer userData)
@@ -120,6 +122,13 @@
         g_assert_nonnull(scheme);
         g_assert_true(test->m_handlersMap.contains(String::fromUTF8(scheme)));
 
+        const char* method = webkit_uri_scheme_request_get_http_method(request);
+        g_assert_nonnull(method);
+        if (!g_strcmp0(scheme, "post"))
+            g_assert_cmpstr(method, ==, "POST");
+        else
+            g_assert_cmpstr(method, ==, "GET");
+
         const URISchemeHandler& handler = test->m_handlersMap.get(String::fromUTF8(scheme));
 
         GRefPtr<GInputStream> inputStream = adoptGRef(g_memory_input_stream_new());
@@ -154,12 +163,15 @@
         else if (!handler.reply.isNull())
             g_memory_input_stream_add_data(G_MEMORY_INPUT_STREAM(inputStream.get()), handler.reply.data(), handler.reply.length(), 0);
 
-        webkit_uri_scheme_request_finish(request, inputStream.get(), handler.replyLength, handler.mimeType.data());
+        auto response = adoptGRef(webkit_uri_scheme_response_new(inputStream.get(), handler.replyLength));
+        webkit_uri_scheme_response_set_status(response.get(), handler.statusCode, nullptr);
+        webkit_uri_scheme_response_set_content_type(response.get(), handler.mimeType.data());
+        webkit_uri_scheme_request_finish_with_response(request, response.get());
     }
 
-    void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType)
+    void registerURISchemeHandler(const char* scheme, const char* reply, int replyLength, const char* mimeType, int statusCode = 200)
     {
-        m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType));
+        m_handlersMap.set(String::fromUTF8(scheme), URISchemeHandler(reply, replyLength, mimeType, statusCode));
         webkit_web_context_register_uri_scheme(m_webContext.get(), scheme, uriSchemeRequestCallback, this, 0);
     }
 
@@ -297,6 +309,31 @@
     g_assert_true(test->m_loadFailed);
     g_assert_error(test->m_error.get(), G_IO_ERROR, G_IO_ERROR_CLOSED);
 
+    test->registerURISchemeHandler("notfound", kBarHTML, strlen(kBarHTML), "text/html", 404);
+    test->m_loadEvents.clear();
+    test->loadURI("notfound:blank");
+    test->waitUntilLoadFinished();
+    g_assert_false(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+
+    test->registerURISchemeHandler("nocontent", nullptr, 0, "application/json", 204);
+    test->m_loadEvents.clear();
+    test->loadURI("nocontent:blank");
+    test->waitUntilLoadFinished();
+    g_assert_false(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+    g_assert_false(test->m_loadEvents.contains(LoadTrackingTest::LoadFailed));
+
+    static const char* formHTML = "<html><body><form id=\"test-form\" method=\"POST\" action=""
+    test->registerURISchemeHandler("post", nullptr, 0, "application/json", 204);
+    test->m_loadEvents.clear();
+    test->loadHtml(formHTML, "post:form");
+    test->waitUntilLoadFinished();
+    GUniqueOutPtr<GError> postError;
+    test->runJavaScriptAndWaitUntilFinished("document.getElementById('test-form').submit()", &postError.outPtr());
+    g_assert_no_error(postError.get());
+    test->waitUntilLoadFinished();
+    g_assert_false(test->m_loadEvents.contains(LoadTrackingTest::ProvisionalLoadFailed));
+    g_assert_false(test->m_loadEvents.contains(LoadTrackingTest::LoadFailed));
+
     // Torture test time: make sure it still works if we issue a bunch of different requests all at
     // once. Each request should finish and return exactly the same data.
     int numIterations = 25;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to