Bug 129379 - Provide webkit_uri_request_get_soup_message for adding custom POST data
Summary: Provide webkit_uri_request_get_soup_message for adding custom POST data
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tomas Popela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-26 10:39 PST by Sami Wagiaalla
Modified: 2017-12-14 09:45 PST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sami Wagiaalla 2014-02-26 10:39:12 PST
The Eclipse SWT Browser which uses WebKit1GTK provides API in Java for appending custom POST data.
To achieve this webkit_network_request_get_message was used to get the SoupMessage during resource-request-starting signal

In WebKit2Gtk one can create a custom request then load it using webkit_web_view_load_request however there is no way to get the SoupMessage of that request in order to customize it.

It would be great if WebKitURIRequest had a function webkit_uri_request_get_soup_message so that one can add custom POST data and customize the request in general.
Comment 1 Martin Robinson 2014-03-02 10:22:35 PST
The SoupMessage is in another process entirely, so giving access to the SoupMessage in the UIProcess is not an option.
Comment 2 Carlos Garcia Campos 2014-03-02 10:41:25 PST
(In reply to comment #1)
> The SoupMessage is in another process entirely, so giving access to the SoupMessage in the UIProcess is not an option.

WebKitURIRequest is common to UI and web process APIs. We can't return the soup message because in multiprocess mode, the network is in the network process, but maybe we could add API to WebKitURIRequest to add custom post data, that would be serialized and sent to the network process, the same way we can add custom http headers or set a new URI. I haven't looked at the details, though. Sami, could you point me to the code you have for WebKit1?
Comment 3 Sami Wagiaalla 2014-03-10 08:25:39 PDT
Hi Carlos,

Sorry for the delayed reply.

> I haven't looked at the details, though. Sami, could you point me to the code you have for WebKit1?

The class which contains most of the implementation is can be viewed here: http://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20WebKit/gtk/org/eclipse/swt/browser/WebKit.java

In line 1768 I use webkit_uri_request_get_http_headers get the headers object to add custom headers. If I understood your explanation correctly this is not the actual header object from the soup message but a temporary container the content of which get serialized, sent to the network process and later appended to the header object of the actual soup message.

The old code which customized POST data starts in line 2215:
There is a lot of Java stuff converting the Java string into a C allocating memory etc but the key function call is

WebKitGTK.soup_message_body_append (body, WebKitGTK.SOUP_MEMORY_TAKE, data, bytes.length);

Thanks for looking into this!
Comment 4 Leo Ufimtsev 2017-12-12 11:52:53 PST
In the meantime:
- We've implemented a workaround.
We use Java to do a http request where we set the postData ourselfes. Then we load webkit2 with the resulting result form the server.
It's not ideal, but works.
(If curious: https://git.eclipse.org/r/#/c/112732/16/bundles/org.eclipse.swt/Eclipse+SWT+WebKit/gtk/org/eclipse/swt/browser/WebKit.java)

- Yea, ideally, we just need a way to set the method to be 'post' and manually set the postData.

Example post calls:
1) Query bugzilla:
 URL:  https://bugs.eclipse.org/bugs/buglist.cgi
 PostData payload: emailassigned_to1=1&bug_severity=enhancement&bug_status=NEW&email1=platform-swt-inbox&emailtype1=substring
  (Something like this can be done via URL/GET but has length limit of 20** chars. Post has no length limit).

2) Query some server with custom data:
 URL: http://httpbin.org/post
 PostData payload: Plain text passed as postData
 Header/content type: content-type: text/plain; charset=UTF-8

If this does get implemented at one point, may we please kindly request you to post a comment in our bugzilla as we lack bugs.webkit.org hooks: 
https://bugs.eclipse.org/bugs/show_bug.cgi?id=528550

Thank you!
Comment 5 Michael Catanzaro 2017-12-14 09:45:17 PST
Tom, what are you planning to do here? "Provide webkit_uri_request_get_soup_message" is of course impossible, since the SoupMessage lives in the network process.