mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1421094 - nsIUploadChannel2.cloneUploadStream returns the length of the stream, r=smaug
This commit is contained in:
parent
da0a8f053e
commit
5f1be317f0
@ -1335,6 +1335,7 @@ class FetchEventRunnable : public ExtendableFunctionalEventWorkerRunnable
|
||||
RequestCredentials mRequestCredentials;
|
||||
nsContentPolicyType mContentPolicyType;
|
||||
nsCOMPtr<nsIInputStream> mUploadStream;
|
||||
int64_t mUploadStreamContentLength;
|
||||
nsCString mReferrer;
|
||||
ReferrerPolicy mReferrerPolicy;
|
||||
nsString mIntegrity;
|
||||
@ -1363,6 +1364,7 @@ public:
|
||||
// send credentials to same-origin websites unless explicitly forbidden.
|
||||
, mRequestCredentials(RequestCredentials::Same_origin)
|
||||
, mContentPolicyType(nsIContentPolicy::TYPE_INVALID)
|
||||
, mUploadStreamContentLength(-1)
|
||||
, mReferrer(kFETCH_CLIENT_REFERRER_STR)
|
||||
, mReferrerPolicy(ReferrerPolicy::_empty)
|
||||
{
|
||||
@ -1496,7 +1498,8 @@ public:
|
||||
if (uploadChannel) {
|
||||
MOZ_ASSERT(!mUploadStream);
|
||||
nsCOMPtr<nsIInputStream> uploadStream;
|
||||
rv = uploadChannel->CloneUploadStream(getter_AddRefs(uploadStream));
|
||||
rv = uploadChannel->CloneUploadStream(&mUploadStreamContentLength,
|
||||
getter_AddRefs(uploadStream));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mUploadStream = uploadStream;
|
||||
}
|
||||
@ -1606,7 +1609,7 @@ private:
|
||||
mReferrerPolicy,
|
||||
mContentPolicyType,
|
||||
mIntegrity);
|
||||
internalReq->SetBody(mUploadStream, -1);
|
||||
internalReq->SetBody(mUploadStream, mUploadStreamContentLength);
|
||||
// For Telemetry, note that this Request object was created by a Fetch event.
|
||||
internalReq->SetCreatedByFetchEvent();
|
||||
|
||||
|
@ -61,7 +61,9 @@ interface nsIUploadChannel2 : nsISupports
|
||||
* Clones the upload stream. May return failure if the upload stream
|
||||
* is not cloneable. If this is not acceptable, use the
|
||||
* ensureUploadStreamIsCloneable() method first.
|
||||
* aContentLength could be -1 in case the size of the stream is unknown,
|
||||
* otherwise it will contain the known size of the stream.
|
||||
*/
|
||||
[noscript]
|
||||
nsIInputStream cloneUploadStream();
|
||||
nsIInputStream cloneUploadStream(out long long aContentLength);
|
||||
};
|
||||
|
@ -995,8 +995,10 @@ HttpBaseChannel::EnsureUploadStreamIsCloneableComplete(nsresult aStatus)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
HttpBaseChannel::CloneUploadStream(nsIInputStream** aClonedStream)
|
||||
HttpBaseChannel::CloneUploadStream(int64_t* aContentLength,
|
||||
nsIInputStream** aClonedStream)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aContentLength);
|
||||
NS_ENSURE_ARG_POINTER(aClonedStream);
|
||||
*aClonedStream = nullptr;
|
||||
|
||||
@ -1010,6 +1012,12 @@ HttpBaseChannel::CloneUploadStream(nsIInputStream** aClonedStream)
|
||||
|
||||
clonedStream.forget(aClonedStream);
|
||||
|
||||
if (mReqContentLengthDetermined) {
|
||||
*aContentLength = mReqContentLength;
|
||||
} else {
|
||||
*aContentLength = -1;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user