Bug 252564

Summary: [GLib] New API to get the request body of WebKitURISchemeRequest
Product: WebKit Reporter: Yu-Wei Wu <wusyong9104>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: aperez, bugs-noreply, cgarcia, mcatanzaro, pgriffis
Priority: P2    
Version: Other   
Hardware: PC   
OS: Linux   

Description Yu-Wei Wu 2023-02-20 07:17:56 PST
At the moment WebKitURISchemeRequest can access HTTP headers and methods but not the body. I would like to help add the body-getter for this type.

It looks like we can call ResourceRequest::updateSoupMessageBody to get the body. However, its parameters require a type BlobRegistryImpl&. I'm not sure how do I get this. Can I just call blobRegistry() and then pass to it?
Comment 1 Michael Catanzaro 2023-02-20 07:44:17 PST
You'd probably need to revert https://commits.webkit.org/260252@main... better talk to Carlos Garcia about this.
Comment 2 Yu-Wei Wu 2023-02-20 08:32:15 PST
That commit doesn't seem to affect ResourceRequest::updateSoupMessageBody. This method also calls methods from ResourceRequestBase itself. Or is there somewhere else that will make its body missing when calling updateSoupMessageBody?
Comment 3 Michael Catanzaro 2023-02-20 09:19:15 PST
It's impossible to get the message body outside the network process because it's not serialized anymore.

ResourceRequest::updateSoupMessageBody is not a way to get the message body.
Comment 4 Patrick Griffis 2023-02-20 09:42:23 PST
I left some comments on the upstream Tauri bug for this: https://github.com/tauri-apps/wry/issues/666

My general feeling was also that this is tricky or impossible to do efficiently.
Comment 5 Carlos Garcia Campos 2023-02-21 00:58:00 PST
For custom uri schemes, it's the application the one providing the http body from the UI process, so I don't understand why you need a way to get it again.
Comment 6 Yu-Wei Wu 2023-02-21 01:53:20 PST
(In reply to Carlos Garcia Campos from comment #5)
> For custom uri schemes, it's the application the one providing the http body
> from the UI process, so I don't understand why you need a way to get it
> again.

It could be asking users to fill a form with POST method. Without HTTP body, we can't get the data from the form. It's common to send requests with the body containing some data IMHO.

Btw I tried to test a bit, and it seems the httpBody of the ResourceRequest is still valid when calling the URI scheme callback. Take above form as an example, I can get "name=John" if users type the name into the form. I suppose it's still possible to create a soup message body from it? Or should it just transfer the ownership into the callback?
Comment 7 Yu-Wei Wu 2023-02-26 22:54:23 PST
Pull request: https://github.com/WebKit/WebKit/pull/10714
Comment 8 EWS 2023-02-28 09:43:23 PST
Committed 260949@main (5fe923aa166a): <https://commits.webkit.org/260949@main>

Reviewed commits have been landed. Closing PR #10714 and removing active labels.