Bug 138131

Summary: File uploads not working with a custom NSURLProtocol
Product: WebKit Reporter: Daniel <danielo>
Component: WebKit APIAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: andersca, ap, benjamin, carlos, sam, stuartmorgan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: iPhone / iPad   
OS: Unspecified   
URL: http://imgur.com/
See Also: https://bugs.webkit.org/show_bug.cgi?id=137302
https://bugs.webkit.org/show_bug.cgi?id=137299
Bug Depends on: 137299    
Bug Blocks:    

Description Daniel 2014-10-28 06:41:25 PDT
The file upload using input type="file" or FormData API is not working when the URL is loaded using a custom NSURLProtocol.

If a custom NSURLProtocol is handling an HTTP POST request, the request HTTPBodyStream is nil.
This only happens if [WKBrowsingContextController registerSchemeForCustomProtocol:] is called for that protocol. If this method is not called, then the POST request is simply bypassing the custom protocol.

This happens, because HTTP body stream (NSURLRequest.HTTPBodyStream) is not serialized in IPC messages when sending the request from the networking process to the UI process.
See http://trac.webkit.org/browser/trunk/Source/WebKit2/Shared/mac/WebCoreArgumentCodersMac.mm#L93 :
    [(NSMutableURLRequest *)requestToSerialize setHTTPBodyStream:nil];

This happens on iOS 8.1 [12B401].
It's also reproducible on the master branch ( 809db5f8edac632ec3332b43dc90795d96914440 ).

This bug is related to https://bugs.webkit.org/show_bug.cgi?id=137299