mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1494176 - nsHttpChannel must clone the upload stream if it doesn't implement ::Seek(), r=mayhemer
This commit is contained in:
parent
38b412e89d
commit
165f1339fd
@ -914,9 +914,20 @@ HttpBaseChannel::EnsureUploadStreamIsCloneable(nsIRunnable* aCallback)
|
||||
// this is called more than once simultaneously.
|
||||
NS_ENSURE_FALSE(mUploadCloneableCallback, NS_ERROR_UNEXPECTED);
|
||||
|
||||
// If the CloneUploadStream() will succeed, then synchronously invoke
|
||||
// the callback to indicate we're already cloneable.
|
||||
if (!mUploadStream || NS_InputStreamIsCloneable(mUploadStream)) {
|
||||
// We can immediately exec the callback if we don't have an upload stream.
|
||||
if (!mUploadStream) {
|
||||
aCallback->Run();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Some nsSeekableStreams do not implement ::Seek() (see nsPipeInputStream).
|
||||
// In this case, we must clone the uploadStream into a memory stream in order
|
||||
// to have it seekable. If the CloneUploadStream() will succeed, then
|
||||
// synchronously invoke the callback to indicate we're already cloneable.
|
||||
nsCOMPtr<nsISeekableStream> seekable = do_QueryInterface(mUploadStream);
|
||||
if (seekable &&
|
||||
NS_SUCCEEDED(seekable->Seek(nsISeekableStream::NS_SEEK_SET, 0)) &&
|
||||
NS_InputStreamIsCloneable(mUploadStream)) {
|
||||
aCallback->Run();
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -718,6 +718,15 @@ HttpChannelParent::DoAsyncOpen( const URIParams& aURI,
|
||||
})
|
||||
->Track(mRequest);
|
||||
|
||||
// The stream, received from the child process, must be cloneable and seekable
|
||||
// in order to allow devtools to inspect its content.
|
||||
nsCOMPtr<nsIRunnable> r =
|
||||
NS_NewRunnableFunction("HttpChannelParent::EnsureUploadStreamIsCloneable",
|
||||
[self]() {
|
||||
self->TryInvokeAsyncOpen(NS_OK);
|
||||
});
|
||||
++mAsyncOpenBarrier;
|
||||
mChannel->EnsureUploadStreamIsCloneable(r);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -741,7 +750,7 @@ HttpChannelParent::WaitForBgParent()
|
||||
return promise.forget();
|
||||
}
|
||||
|
||||
return mPromise.Ensure(__func__);;
|
||||
return mPromise.Ensure(__func__);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -1528,7 +1528,6 @@ nsPipeInputStream::AsyncWait(nsIInputStreamCallback* aCallback,
|
||||
NS_IMETHODIMP
|
||||
nsPipeInputStream::Seek(int32_t aWhence, int64_t aOffset)
|
||||
{
|
||||
MOZ_ASSERT_UNREACHABLE("nsPipeInputStream::Seek");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user