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

Side by Side Diff: Source/modules/fetch/FetchManager.cpp

Issue 1301523002: [Fetch API] Send request body as a FormData. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "modules/fetch/FetchManager.h" 6 #include "modules/fetch/FetchManager.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/ScriptPromiseResolver.h" 9 #include "bindings/core/v8/ScriptPromiseResolver.h"
10 #include "bindings/core/v8/ScriptState.h" 10 #include "bindings/core/v8/ScriptState.h"
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 // FIXME: Support body. 351 // FIXME: Support body.
352 ResourceRequest request(m_request->url()); 352 ResourceRequest request(m_request->url());
353 request.setRequestContext(m_request->context()); 353 request.setRequestContext(m_request->context());
354 request.setHTTPMethod(m_request->method()); 354 request.setHTTPMethod(m_request->method());
355 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList( )->list(); 355 const Vector<OwnPtr<FetchHeaderList::Header>>& list = m_request->headerList( )->list();
356 for (size_t i = 0; i < list.size(); ++i) { 356 for (size_t i = 0; i < list.size(); ++i) {
357 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second)); 357 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second));
358 } 358 }
359 359
360 if (m_request->method() != "GET" && m_request->method() != "HEAD") { 360 if (m_request->method() != "GET" && m_request->method() != "HEAD") {
361 if (BodyStreamBuffer* buffer = m_request->buffer()) { 361 if (m_request->buffer()->hasBody()) {
362 RefPtr<BlobDataHandle> blobDataHandle = buffer->drainAsBlobDataHandl e(FetchDataConsumerHandle::Reader::AllowBlobWithInvalidSize); 362 request.setHTTPBody(m_request->buffer()->drainAsFormData());
363 RefPtr<FormData> httpBody(FormData::create());
364 if (blobDataHandle)
365 httpBody->appendBlob(blobDataHandle->uuid(), blobDataHandle);
366 request.setHTTPBody(httpBody);
367 } 363 }
368 } 364 }
369 request.setFetchRedirectMode(m_request->redirect()); 365 request.setFetchRedirectMode(m_request->redirect());
370 request.setUseStreamOnResponse(true); 366 request.setUseStreamOnResponse(true);
371 367
372 // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer| 368 // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer|
373 // is none, and `Referer`/|HTTPRequest|'s referrer, serialized and utf-8 369 // is none, and `Referer`/|HTTPRequest|'s referrer, serialized and utf-8
374 // encoded, otherwise, to HTTPRequest's header list. 370 // encoded, otherwise, to HTTPRequest's header list.
375 // We set the referrer using workerGlobalScope's URL in 371 // We set the referrer using workerGlobalScope's URL in
376 // WorkerThreadableLoader. 372 // WorkerThreadableLoader.
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 484
489 DEFINE_TRACE(FetchManager) 485 DEFINE_TRACE(FetchManager)
490 { 486 {
491 #if ENABLE(OILPAN) 487 #if ENABLE(OILPAN)
492 visitor->trace(m_executionContext); 488 visitor->trace(m_executionContext);
493 visitor->trace(m_loaders); 489 visitor->trace(m_loaders);
494 #endif 490 #endif
495 } 491 }
496 492
497 } // namespace blink 493 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698