Bug 191362 - XMLHTTPRequest POSTs to a custom WKURLSchemeHandler protocol are missing the HTTP body
Summary: XMLHTTPRequest POSTs to a custom WKURLSchemeHandler protocol are missing the ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: Safari 12
Hardware: iPhone / iPad iOS 12
: P2 Normal
Assignee: Brady Eidson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-11-07 07:34 PST by erezg
Modified: 2019-04-24 15:09 PDT (History)
7 users (show)

See Also:


Attachments
minimal repro iOS app (24.81 KB, application/zip)
2019-04-23 18:17 PDT, Patrick Yang
no flags Details
Patch (10.47 KB, patch)
2019-04-24 13:43 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff
Patch (10.11 KB, patch)
2019-04-24 14:41 PDT, Brady Eidson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description erezg 2018-11-07 07:34:21 PST
POST requests made through the WKURLSchemeHandler get an empty POST payload in the task's request.
This leads to lack of data passed on to the handler from WKWebView.
Comment 1 Alex Christensen 2018-11-07 14:52:42 PST
I feel like this has been recently fixed, but I'm not sure.  In what version are you seeing this issue?
Comment 2 erezg 2018-11-12 05:45:30 PST
This is true in iOS 12.1 and also in the latest commit I have from the WebKit source - 7ac42d35cb98a00f22847ba51503489dbeb9ab49
Comment 3 Patrick Yang 2019-04-23 18:15:57 PDT
This reproduces for me in an iOS 12.2 simulator built from XCode 10.2.1.
Comment 4 Patrick Yang 2019-04-23 18:17:32 PDT
Created attachment 368095 [details]
minimal repro iOS app

Minimal repro iOS app.

Prints !! to console when the webview is loaded, demonstrating that the request is being forwarded to the WKURLSchemeHandler.  The printed request body is nil.
Comment 5 Brady Eidson 2019-04-23 18:31:44 PDT
(In reply to Alex Christensen from comment #1)
> I feel like this has been recently fixed, but I'm not sure.  In what version
> are you seeing this issue?

Yup we fixed it and have a passing test for the fix.

Form POST navigations work great.

The test app is an XHR POST which follows a different code path and is indeed broken

(People this is why giving as much information as possible - especially repro test cases - is important!)

Iā€™m almost done with a fix.
Comment 6 Brady Eidson 2019-04-24 11:33:10 PDT
In my upcoming fix, POSTing a blob via XHR will still be broken.

See https://bugs.webkit.org/show_bug.cgi?id=197237
Comment 7 Brady Eidson 2019-04-24 13:09:12 PDT
Retitle for clarity:
XMLHTTPRequest POSTs to a custom WKURLSchemeHandler protocol are missing the HTTP body
Comment 8 Brady Eidson 2019-04-24 13:43:34 PDT
Created attachment 368170 [details]
Patch
Comment 9 Build Bot 2019-04-24 13:46:14 PDT
Attachment 368170 [details] did not pass style-queue:


ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:585:  Multi-line string ("...") found.  This lint script doesn't do well with such strings, and may give bogus warnings.  They're ugly and unnecessary, and you should use concatenation instead".  [readability/multiline_string] [5]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:590:  Missing spaces around /  [whitespace/operators] [3]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:601:  Missing spaces around /  [whitespace/operators] [3]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:602:  Missing spaces around =  [whitespace/operators] [4]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:606:  Missing spaces around /  [whitespace/operators] [3]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:611:  Missing spaces around /  [whitespace/operators] [3]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:629:  Multi-line string ("...") found.  This lint script doesn't do well with such strings, and may give bogus warnings.  They're ugly and unnecessary, and you should use concatenation instead".  [readability/multiline_string] [5]
Total errors found: 7 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 10 Alex Christensen 2019-04-24 14:10:06 PDT
Comment on attachment 368170 [details]
Patch

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

> Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:653
> +            printf("%u %u %u %u %u %u %u %u\n", ((char*)task.request.HTTPBody.bytes)[0], ((char*)task.request.HTTPBody.bytes)[1], ((char*)task.request.HTTPBody.bytes)[2], ((char*)task.request.HTTPBody.bytes)[3], ((char*)task.request.HTTPBody.bytes)[4], ((char*)task.request.HTTPBody.bytes)[5], ((char*)task.request.HTTPBody.bytes)[6], ((char*)task.request.HTTPBody.bytes)[7]);

:(
Comment 11 Brady Eidson 2019-04-24 14:14:17 PDT
(In reply to Alex Christensen from comment #10)
> Comment on attachment 368170 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=368170&action=review
> 
> > Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:653
> > +            printf("%u %u %u %u %u %u %u %u\n", ((char*)task.request.HTTPBody.bytes)[0], ((char*)task.request.HTTPBody.bytes)[1], ((char*)task.request.HTTPBody.bytes)[2], ((char*)task.request.HTTPBody.bytes)[3], ((char*)task.request.HTTPBody.bytes)[4], ((char*)task.request.HTTPBody.bytes)[5], ((char*)task.request.HTTPBody.bytes)[6], ((char*)task.request.HTTPBody.bytes)[7]);
> 
> :(

Yup - Have the fix and will upload it for landing after this current patch clears EWS.
Comment 12 Brady Eidson 2019-04-24 14:41:16 PDT
Created attachment 368177 [details]
Patch
Comment 13 Build Bot 2019-04-24 14:44:02 PDT
Attachment 368177 [details] did not pass style-queue:


ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:585:  Multi-line string ("...") found.  This lint script doesn't do well with such strings, and may give bogus warnings.  They're ugly and unnecessary, and you should use concatenation instead".  [readability/multiline_string] [5]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:590:  Missing spaces around /  [whitespace/operators] [3]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:601:  Missing spaces around /  [whitespace/operators] [3]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:602:  Missing spaces around =  [whitespace/operators] [4]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:606:  Missing spaces around /  [whitespace/operators] [3]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:611:  Missing spaces around /  [whitespace/operators] [3]
ERROR: Tools/TestWebKitAPI/Tests/WebKitCocoa/WKURLSchemeHandler-1.mm:629:  Multi-line string ("...") found.  This lint script doesn't do well with such strings, and may give bogus warnings.  They're ugly and unnecessary, and you should use concatenation instead".  [readability/multiline_string] [5]
Total errors found: 7 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 14 WebKit Commit Bot 2019-04-24 15:03:10 PDT
Comment on attachment 368177 [details]
Patch

Clearing flags on attachment: 368177

Committed r244617: <https://trac.webkit.org/changeset/244617>
Comment 15 WebKit Commit Bot 2019-04-24 15:03:12 PDT
All reviewed patches have been landed.  Closing bug.
Comment 16 Radar WebKit Bug Importer 2019-04-24 15:09:36 PDT
<rdar://problem/50183483>