WKWebViewTips icon indicating copy to clipboard operation
WKWebViewTips copied to clipboard

WKWebView does not response correct MimeType in `decidePolicyForNavigationResponse`

Open TheMrugraj opened this issue 5 years ago • 0 comments

I want to detect the response MimeType so that accordingly handle the type of file that's being downloaded. So, for example, if the file type is application/vnd.ms-excel then I want to take certain action but, with WKWebView it is always returning text/html in

-(void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler

I noticed that if I debug the WKWebView using Safari then the response MimeType is correctly displaying as application/vnd.ms-excel but, maybe because of QuickLook feature available in WkWebView the content is getting converted into HTML and responding text/html.

Is there any way to detect the mimeType apart from the above option that returns the actual file's mimeType?

https://stackoverflow.com/questions/62009832/wkwebview-does-not-response-correct-mimetype-in-decidepolicyfornavigationrespon

TheMrugraj avatar May 26 '20 11:05 TheMrugraj