Bug 222471 - [WPE][GTK] Bogus Response.{status,ok} for successful fetch() requests to a custom URI scheme handler
Summary: [WPE][GTK] Bogus Response.{status,ok} for successful fetch() requests to a cu...
Alias: None
Product: WebKit
Classification: Unclassified
Component: WPE WebKit (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adrian Perez
Depends on:
Reported: 2021-02-26 06:58 PST by Adrian Perez
Modified: 2021-11-03 01:29 PDT (History)
6 users (show)

See Also:

Patch (1.93 KB, patch)
2021-02-26 08:45 PST, Adrian Perez
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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);

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]
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]

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.