Opaque being-loaded responses should clone their body
[WebKit-https.git] / Source / WebCore / Modules / fetch / FetchBodyOwner.cpp
index 9de02112eb963a9936367e47afe3460974fcbafd..3daf92906b346d32a9f6ae26789e7a04f4aaa6c2 100644 (file)
@@ -290,19 +290,24 @@ RefPtr<ReadableStream> FetchBodyOwner::readableStream(JSC::ExecState& state)
     if (isBodyNullOrOpaque())
         return nullptr;
 
-    if (!m_body->hasReadableStream()) {
-        ASSERT(!m_readableStreamSource);
-        if (isDisturbed()) {
-            m_body->setReadableStream(ReadableStream::create(state, nullptr));
-            m_body->readableStream()->lock();
-        } else {
-            m_readableStreamSource = adoptRef(*new FetchBodySource(*this));
-            m_body->setReadableStream(ReadableStream::create(state, m_readableStreamSource));
-        }
-    }
+    if (!m_body->hasReadableStream())
+        createReadableStream(state);
+
     return m_body->readableStream();
 }
 
+void FetchBodyOwner::createReadableStream(JSC::ExecState& state)
+{
+    ASSERT(!m_readableStreamSource);
+    if (isDisturbed()) {
+        m_body->setReadableStream(ReadableStream::create(state, nullptr));
+        m_body->readableStream()->lock();
+    } else {
+        m_readableStreamSource = adoptRef(*new FetchBodySource(*this));
+        m_body->setReadableStream(ReadableStream::create(state, m_readableStreamSource));
+    }
+}
+
 void FetchBodyOwner::consumeBodyAsStream()
 {
     ASSERT(m_readableStreamSource);