| Index: third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
|
| diff --git a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
|
| index 1dd4bd18b16169f0fd4bb7a5f269e0b06a5ff209..11b50f742a10d067ed13b596b2655d051a6fef77 100644
|
| --- a/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
|
| +++ b/third_party/WebKit/Source/modules/fetch/BodyStreamBuffer.cpp
|
| @@ -232,8 +232,9 @@ void BodyStreamBuffer::tee(BodyStreamBuffer** branch1, BodyStreamBuffer** branch
|
|
|
| ScriptPromise BodyStreamBuffer::pull(ScriptState* scriptState)
|
| {
|
| - ASSERT(!m_streamNeedsMore);
|
| ASSERT(scriptState == m_scriptState.get());
|
| + if (m_streamNeedsMore)
|
| + return ScriptPromise::castUndefined(scriptState);
|
| m_streamNeedsMore = true;
|
| processData();
|
| return ScriptPromise::castUndefined(scriptState);
|
| @@ -355,9 +356,15 @@ void BodyStreamBuffer::processData()
|
| switch (result) {
|
| case WebDataConsumerHandle::Ok: {
|
| DOMUint8Array* array = DOMUint8Array::create(static_cast<const unsigned char*>(buffer), available);
|
| - controller()->enqueue(array);
|
| - m_streamNeedsMore = controller()->desiredSize() > 0;
|
| m_reader->endRead(available);
|
| + // Clear m_streamNeedsMore in order to detect a pull call.
|
| + m_streamNeedsMore = false;
|
| + controller()->enqueue(array);
|
| + // If m_streamNeedsMore is true, it means that pull is called and
|
| + // the stream needs more data even if the desired size is not
|
| + // positive.
|
| + if (!m_streamNeedsMore)
|
| + m_streamNeedsMore = controller()->desiredSize() > 0;
|
| break;
|
| }
|
| case WebDataConsumerHandle::Done:
|
|
|