Bug 222471

Summary: [WPE][GTK] Bogus Response.{status,ok} for successful fetch() requests to a custom URI scheme handler
Product: WebKit Reporter: Adrian Perez <aperez>
Component: WPE WebKitAssignee: Adrian Perez <aperez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, berto, bugs-noreply, cgarcia, ews-watchlist, gustavo
Priority: P2    
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=203273
Attachments:
Description Flags
Patch none

Description Adrian Perez 2021-02-26 06:58:08 PST
Steps to reproduce:

 1. Use webkit_web_context_register_uri_scheme(), e.g. "myscheme",
    make the callback always finish requests with a valid GInputStream
    (for example, return the "Hello world" string for any requested URI).

 2. Load a page that contains this:

      fetch("myscheme:/someresource", {mode: "no-cors"})
          .then(response => {
              console.log("Status:", response.ok, response.status)
              response.text().then(text => {
                  console.log("Text:", text);
              });
          })
          .catch(console.error);

Expected outcome
----------------

 * The response is considered successful.
 * The logged output contains:

    Status: true 200
    Text: Hello, world

Actual outcome
--------------

 * The response is NOT considered successful, yet the
 * The logged output contains:
   Status: false 0
   Text: Hello, world
Comment 1 Adrian Perez 2021-02-26 07:00:23 PST
This is somewhat related to bug #203273 but much, much smaller in
scope, and I think setting the status to “200 OK” when an URI scheme
request is finished with a valid “GInputStreams” should not be
controversial, so let's tackle this small annoyance first.
Comment 2 Adrian Perez 2021-02-26 08:45:48 PST
Created attachment 421653 [details]
Patch
Comment 3 EWS Watchlist 2021-02-26 08:47:00 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 4 EWS 2021-02-26 23:24:35 PST
Committed r273618: <https://commits.webkit.org/r273618>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 421653 [details].
Comment 5 Alex Christensen 2021-11-02 09:12:22 PDT
Comment on attachment 421653 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=421653&action=review

> Source/WebKit/ChangeLog:8
> +        No new tests needed.

This should be easy to add a unit test for, especially if you care about not regressing this functionality in the future.
Comment 6 Carlos Garcia Campos 2021-11-03 01:29:36 PDT
We have recently added api to set the response, including api tests for checking the status and message.