Closed Bug 915036 Opened 6 years ago Closed 3 years ago
The JS Downloads API should allow sending an upload stream (POST data) with the download request
58 bytes, text/x-review-board-request
Many web sites require some POST data to be sent along with the request which initiates a file download. In order to have feature parity with the old download API the caller must be able to specify at least the upload stream to be sent, or even better to initialize its own channel / have a chance to grab the channel for further customization.
The first thing that comes to my mind is to set callbacks on the DownloadSource object, like: Promise<nsIInputStream> getPostDataStream() Promise adjustChannel(nsIChannel aChannel) Promise<nsIRequestObserver> getRequestObserver(); However, these would need special handling during serialization across different sessions, either making the Download object non-serializable, or requiring special handling during deserialization by the code that set the callback originally, which I'm not sure how to obtain (might be a custom DownloadSaver type). We should definitely put some more thought on this to get it right. In any case we should not allow the POST data to be set as a string in the JSON file, for performance reasons, as the upload stream can be quite long. Maybe there is an alternative storage that could be used externally, like the session store or the cache.
Taking as part of bug 1247793.
Assignee: nobody → tomica
Status: NEW → ASSIGNED
I decided to test the whole thing here (custom headers + POST), since this bug was originally exactly about that: uploading POST data.
Attachment #8803342 - Flags: review?(paolo.mozmail)
Looks great, I'll read through it one more time before r+ but I don't expect any major changes. I don't remember right now what would be the naming convention for callbacks, at present we have "onchange" for the Download object but I'm not sure if it's the best naming convention to use here.
Attachment #8803342 - Flags: review?(paolo.mozmail) → review+
By the way, really good job with updating all the comments and places that needed updating :-)
Pushed by firstname.lastname@example.org: https://hg.mozilla.org/integration/autoland/rev/656db2159f13 Implement DownloadSource.adjustChannel callback to support POST requests r=Paolo
You need to log in before you can comment on or make changes to this bug.