Bug 138131 - File uploads not working with a custom NSURLProtocol
Summary: File uploads not working with a custom NSURLProtocol
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 528+ (Nightly build)
Hardware: iPhone / iPad Unspecified
: P2 Normal
Assignee: Nobody
URL: http://imgur.com/
Keywords:
Depends on: 137299
Blocks:
  Show dependency treegraph
 
Reported: 2014-10-28 06:41 PDT by Daniel
Modified: 2016-06-15 16:46 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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