Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: third_party/WebKit/Source/modules/fetch/Request.cpp

Issue 2679563002: [WIP] Expose Request.body property
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/loader/ThreadableLoader.h" 10 #include "core/loader/ThreadableLoader.h"
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 // "If |init|'s body member is present, run these substeps:" 375 // "If |init|'s body member is present, run these substeps:"
376 if (init.body) { 376 if (init.body) {
377 // Perform the following steps: 377 // Perform the following steps:
378 // - "Let |stream| and |Content-Type| be the result of extracting 378 // - "Let |stream| and |Content-Type| be the result of extracting
379 // |init|'s body member." 379 // |init|'s body member."
380 // - "Set |temporaryBody| to |stream|. 380 // - "Set |temporaryBody| to |stream|.
381 // - "If |Content-Type| is non-null and |r|'s request's header list 381 // - "If |Content-Type| is non-null and |r|'s request's header list
382 // contains no header named `Content-Type`, append 382 // contains no header named `Content-Type`, append
383 // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any 383 // `Content-Type`/|Content-Type| to |r|'s Headers object. Rethrow any
384 // exception." 384 // exception."
385 temporaryBody = new BodyStreamBuffer(scriptState, std::move(init.body)); 385 temporaryBody = init.body;
386 if (!init.contentType.isEmpty() && 386 if (!init.contentType.isEmpty() &&
387 !r->getHeaders()->has(HTTPNames::Content_Type, exceptionState)) { 387 !r->getHeaders()->has(HTTPNames::Content_Type, exceptionState)) {
388 r->getHeaders()->append(HTTPNames::Content_Type, init.contentType, 388 r->getHeaders()->append(HTTPNames::Content_Type, init.contentType,
389 exceptionState); 389 exceptionState);
390 } 390 }
391 if (exceptionState.hadException()) 391 if (exceptionState.hadException())
392 return nullptr; 392 return nullptr;
393 } 393 }
394 394
395 // "Set |r|'s request's body to |temporaryBody|. 395 // "Set |r|'s request's body to |temporaryBody|.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 Request* Request::create(ScriptState* scriptState, 434 Request* Request::create(ScriptState* scriptState,
435 const String& input, 435 const String& input,
436 ExceptionState& exceptionState) { 436 ExceptionState& exceptionState) {
437 return create(scriptState, input, Dictionary(), exceptionState); 437 return create(scriptState, input, Dictionary(), exceptionState);
438 } 438 }
439 439
440 Request* Request::create(ScriptState* scriptState, 440 Request* Request::create(ScriptState* scriptState,
441 const String& input, 441 const String& input,
442 const Dictionary& init, 442 const Dictionary& init,
443 ExceptionState& exceptionState) { 443 ExceptionState& exceptionState) {
444 RequestInit requestInit(scriptState->getExecutionContext(), init, 444 RequestInit requestInit(scriptState, init, exceptionState);
445 exceptionState);
446 return createRequestWithRequestOrString(scriptState, nullptr, input, 445 return createRequestWithRequestOrString(scriptState, nullptr, input,
447 requestInit, exceptionState); 446 requestInit, exceptionState);
448 } 447 }
449 448
450 Request* Request::create(ScriptState* scriptState, 449 Request* Request::create(ScriptState* scriptState,
451 Request* input, 450 Request* input,
452 ExceptionState& exceptionState) { 451 ExceptionState& exceptionState) {
453 return create(scriptState, input, Dictionary(), exceptionState); 452 return create(scriptState, input, Dictionary(), exceptionState);
454 } 453 }
455 454
456 Request* Request::create(ScriptState* scriptState, 455 Request* Request::create(ScriptState* scriptState,
457 Request* input, 456 Request* input,
458 const Dictionary& init, 457 const Dictionary& init,
459 ExceptionState& exceptionState) { 458 ExceptionState& exceptionState) {
460 RequestInit requestInit(scriptState->getExecutionContext(), init, 459 RequestInit requestInit(scriptState, init, exceptionState);
461 exceptionState);
462 return createRequestWithRequestOrString(scriptState, input, String(), 460 return createRequestWithRequestOrString(scriptState, input, String(),
463 requestInit, exceptionState); 461 requestInit, exceptionState);
464 } 462 }
465 463
466 Request* Request::create(ScriptState* scriptState, FetchRequestData* request) { 464 Request* Request::create(ScriptState* scriptState, FetchRequestData* request) {
467 return new Request(scriptState, request); 465 return new Request(scriptState, request);
468 } 466 }
469 467
470 Request* Request::create(ScriptState* scriptState, 468 Request* Request::create(ScriptState* scriptState,
471 const WebServiceWorkerRequest& webRequest) { 469 const WebServiceWorkerRequest& webRequest) {
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer); 731 V8HiddenValue::internalBodyBuffer(scriptState->isolate()), bodyBuffer);
734 } 732 }
735 733
736 DEFINE_TRACE(Request) { 734 DEFINE_TRACE(Request) {
737 Body::trace(visitor); 735 Body::trace(visitor);
738 visitor->trace(m_request); 736 visitor->trace(m_request);
739 visitor->trace(m_headers); 737 visitor->trace(m_headers);
740 } 738 }
741 739
742 } // namespace blink 740 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/fetch/FormDataBytesConsumer.cpp ('k') | third_party/WebKit/Source/modules/fetch/Request.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698