| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/fetch/Request.h" | 5 #include "modules/fetch/Request.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/Dictionary.h" | 7 #include "bindings/core/v8/Dictionary.h" |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/dom/ExecutionContext.h" | 9 #include "core/dom/ExecutionContext.h" |
| 10 #include "core/fetch/FetchUtils.h" | 10 #include "core/fetch/FetchUtils.h" |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 if (temporaryBody) | 356 if (temporaryBody) |
| 357 r->m_request->setBuffer(temporaryBody); | 357 r->m_request->setBuffer(temporaryBody); |
| 358 | 358 |
| 359 // "Set |r|'s MIME type to the result of extracting a MIME type from |r|'s | 359 // "Set |r|'s MIME type to the result of extracting a MIME type from |r|'s |
| 360 // request's header list." | 360 // request's header list." |
| 361 r->m_request->setMIMEType(r->m_request->headerList()->extractMIMEType()); | 361 r->m_request->setMIMEType(r->m_request->headerList()->extractMIMEType()); |
| 362 | 362 |
| 363 // "If |input| is a Request object and |input|'s request's body is | 363 // "If |input| is a Request object and |input|'s request's body is |
| 364 // non-null, run these substeps:" | 364 // non-null, run these substeps:" |
| 365 if (inputRequest && inputRequest->bodyBuffer()) { | 365 if (inputRequest && inputRequest->bodyBuffer()) { |
| 366 // "Set |input|'s body to an empty byte stream." | 366 // "Let |dummyStream| be an empty ReadableStream object." |
| 367 inputRequest->m_request->setBuffer(new BodyStreamBuffer(scriptState, cre
ateFetchDataConsumerHandleFromWebHandle(createDoneDataConsumerHandle()))); | 367 auto dummyStream = new BodyStreamBuffer(scriptState, createFetchDataCons
umerHandleFromWebHandle(createDoneDataConsumerHandle())); |
| 368 // "Set |input|'s disturbed flag." | 368 // "Set |input|'s request's body to a new body whose stream is |
| 369 inputRequest->bodyBuffer()->setDisturbed(); | 369 // |dummyStream|." |
| 370 inputRequest->m_request->setBuffer(dummyStream); |
| 371 // "Let |reader| be the result of getting reader from |dummyStream|." |
| 372 // "Read all bytes from |dummyStream| with |reader|." |
| 373 inputRequest->bodyBuffer()->closeAndLockAndDisturb(); |
| 370 } | 374 } |
| 371 | 375 |
| 372 // "Return |r|." | 376 // "Return |r|." |
| 373 return r; | 377 return r; |
| 374 } | 378 } |
| 375 | 379 |
| 376 Request* Request::create(ScriptState* scriptState, const RequestInfo& input, con
st Dictionary& init, ExceptionState& exceptionState) | 380 Request* Request::create(ScriptState* scriptState, const RequestInfo& input, con
st Dictionary& init, ExceptionState& exceptionState) |
| 377 { | 381 { |
| 378 ASSERT(!input.isNull()); | 382 ASSERT(!input.isNull()); |
| 379 if (input.isUSVString()) | 383 if (input.isUSVString()) |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 } | 667 } |
| 664 | 668 |
| 665 DEFINE_TRACE(Request) | 669 DEFINE_TRACE(Request) |
| 666 { | 670 { |
| 667 Body::trace(visitor); | 671 Body::trace(visitor); |
| 668 visitor->trace(m_request); | 672 visitor->trace(m_request); |
| 669 visitor->trace(m_headers); | 673 visitor->trace(m_headers); |
| 670 } | 674 } |
| 671 | 675 |
| 672 } // namespace blink | 676 } // namespace blink |
| OLD | NEW |