HTTP body (e.g., POST form data) is missing in WKNavigationDelegate callbacks

Originator:skagedal
Number:rdar://38999437 Date Originated:29-Mar-2018 05:36 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 11.2
Classification:Other Bug Reproducible:Always
 
Summary:
With UIWebView, we use UIWebViewDelegate’s `webView(_ webView: UIWebView,  shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType)` to hijack a POST request’s HTTP body. 

This is necessary for us to be able to authenticate the user with an external provider. 

We’d like to switch to WKWebView. However, this is not possible to do with the equivalent methods there. The corresponding WKNavigationDelegate method `webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void)` gives an url request with nil http body data

Steps to Reproduce:
- Implement a WKNavigationDelegate
- Submit a form
- In webView:decidePolicyForNavigationAction:decisionHandler:, try to extract the form data via navigationAction.request.HTTPBody

Expected Results:
- non-nil http body 

Actual Results:
- no http body

Version:
iOS 11.2

Notes:
This has been previously reported as WebKit bug https://bugs.webkit.org/show_bug.cgi?id=140188 and Radar at rdar://18399639. Created this as a duplication to provide a use case.

Comments

Still getting this on iOS 12.x in 2019

Hi,

I can confirm that I am seeing this issue as well with the latest iOS 12.3.

My use case is to do with a 3rd party login provider. In this case Microsoft Office 365. The calls to Microsoft is handled just fine but when the redirect happens from their website to the original one I requested, the POST request's body is empty! It should contain the hidden form data that was sent while the user was logging in.

Please Apple please fix this.

Kind regards, Andre

By andrejacobs.unily at May 20, 2019, 11:09 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!