| Index: third_party/WebKit/Source/modules/fetch/Request.cpp
|
| diff --git a/third_party/WebKit/Source/modules/fetch/Request.cpp b/third_party/WebKit/Source/modules/fetch/Request.cpp
|
| index 553e7d79a3e9671cb07c0945619e6751ba51e002..1d64351430c8df0c1cc3eaa15a26c0266e39e19b 100644
|
| --- a/third_party/WebKit/Source/modules/fetch/Request.cpp
|
| +++ b/third_party/WebKit/Source/modules/fetch/Request.cpp
|
| @@ -12,6 +12,7 @@
|
| #include "core/fetch/ResourceLoaderOptions.h"
|
| #include "core/loader/ThreadableLoader.h"
|
| #include "modules/fetch/BodyStreamBuffer.h"
|
| +#include "modules/fetch/DataConsumerHandleUtil.h"
|
| #include "modules/fetch/FetchBlobDataConsumerHandle.h"
|
| #include "modules/fetch/FetchManager.h"
|
| #include "modules/fetch/RequestInit.h"
|
| @@ -50,29 +51,16 @@ FetchRequestData* createCopyOfFetchRequestDataForFetch(ScriptState* scriptState,
|
|
|
| Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Request* inputRequest, const String& inputString, RequestInit& init, ExceptionState& exceptionState)
|
| {
|
| - // "1. Let |temporaryBody| be null."
|
| - BodyStreamBuffer* temporaryBody = nullptr;
|
| -
|
| - if (inputRequest) {
|
| - // We check bodyUsed even when the body is null in spite of the
|
| - // spec. See https://github.com/whatwg/fetch/issues/61 for details.
|
| - if (inputRequest->bodyUsed()) {
|
| - exceptionState.throwTypeError("Cannot construct a Request with a Request object that has already been used.");
|
| - return nullptr;
|
| - }
|
| + // "1. If |input| is a Request object and it is disturbed, throw a
|
| + // TypeError.
|
| + if (inputRequest && inputRequest->bodyUsed()) {
|
| + exceptionState.throwTypeError("Cannot construct a Request with a Request object that has already been used.");
|
| + return nullptr;
|
| }
|
|
|
| - // "2. If |input| is a Request object and |input|'s body is non-null, run
|
| - // these substeps:"
|
| - if (inputRequest && inputRequest->hasBody()) {
|
| - // "1. If |input|'s used flag is set, throw a TypeError."
|
| - // "2. Set |temporaryBody| to |input|'s body."
|
| - if (inputRequest->bodyUsed()) {
|
| - exceptionState.throwTypeError("Cannot construct a Request with a Request object that has already been used.");
|
| - return nullptr;
|
| - }
|
| - temporaryBody = inputRequest->bodyBuffer();
|
| - }
|
| + // "2. Let |temporaryBody| be |input|'s request's body if |input| is a
|
| + // Request object, and null otherwise.
|
| + BodyStreamBuffer* temporaryBody = inputRequest ? inputRequest->bodyBuffer() : nullptr;
|
|
|
| // "3. Let |request| be |input|'s request, if |input| is a Request object,
|
| // and a new request otherwise."
|
| @@ -306,13 +294,11 @@ Request* Request::createRequestWithRequestOrString(ScriptState* scriptState, Req
|
|
|
| // "35. If |input| is a Request object and |input|'s body is non-null, run
|
| // these substeps:"
|
| - // We set bodyUsed even when the body is null in spite of the
|
| - // spec. See https://github.com/whatwg/fetch/issues/61 for details.
|
| - if (inputRequest) {
|
| - // "1. Set |input|'s body to null."
|
| - inputRequest->m_request->setBuffer(nullptr);
|
| - // "2. Set |input|'s used flag."
|
| - inputRequest->setBodyPassed();
|
| + if (inputRequest && inputRequest->bodyBuffer()) {
|
| + // "1. Set |input|'s body to an empty byte stream."
|
| + inputRequest->m_request->setBuffer(new BodyStreamBuffer(createFetchDataConsumerHandleFromWebHandle(createDoneDataConsumerHandle())));
|
| + // "2. Set |input|'s disturbed flag."
|
| + inputRequest->bodyBuffer()->stream()->setIsDisturbed();
|
| }
|
|
|
| // "36. Return |r|."
|
| @@ -551,9 +537,7 @@ Request* Request::clone(ExceptionState& exceptionState)
|
| FetchRequestData* Request::passRequestData()
|
| {
|
| ASSERT(!bodyUsed());
|
| - setBodyPassed();
|
| - FetchRequestData* newRequestData = m_request->pass(executionContext());
|
| - return newRequestData;
|
| + return m_request->pass(executionContext());
|
| }
|
|
|
| bool Request::hasBody() const
|
|
|