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

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

Issue 533123002: [ServiceWorker] Send the body of Request in fetch() API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add ASSERT(m_request->url().protocolIsInHTTPFamily()); Created 6 years, 3 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 "config.h" 5 #include "config.h"
6 #include "FetchManager.h" 6 #include "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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 } 252 }
253 253
254 void FetchManager::Loader::performNetworkError() 254 void FetchManager::Loader::performNetworkError()
255 { 255 {
256 failed(); 256 failed();
257 } 257 }
258 258
259 void FetchManager::Loader::performHTTPFetch() 259 void FetchManager::Loader::performHTTPFetch()
260 { 260 {
261 ASSERT(m_request->url().protocolIsInHTTPFamily());
261 // CORS preflight fetch procedure is implemented inside DocumentThreadableLo ader. 262 // CORS preflight fetch procedure is implemented inside DocumentThreadableLo ader.
262 263
263 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s 264 // "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s
264 // body is a tee of |request|'s body." 265 // body is a tee of |request|'s body."
265 // We use ResourceRequest class for HTTPRequest. 266 // We use ResourceRequest class for HTTPRequest.
266 // FIXME: Support body. 267 // FIXME: Support body.
267 ResourceRequest request(m_request->url()); 268 ResourceRequest request(m_request->url());
268 request.setRequestContext(WebURLRequest::RequestContextFetch); 269 request.setRequestContext(WebURLRequest::RequestContextFetch);
269 request.setDownloadToFile(true); 270 request.setDownloadToFile(true);
270 request.setHTTPMethod(m_request->method()); 271 request.setHTTPMethod(m_request->method());
271 const Vector<OwnPtr<FetchHeaderList::Header> >& list = m_request->headerList ()->list(); 272 const Vector<OwnPtr<FetchHeaderList::Header> >& list = m_request->headerList ()->list();
272 for (size_t i = 0; i < list.size(); ++i) { 273 for (size_t i = 0; i < list.size(); ++i) {
273 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second)); 274 request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(li st[i]->second));
274 } 275 }
275 276
277 if (m_request->method() != "GET" && m_request->method() != "HEAD") {
yhirano 2014/09/04 08:00:55 I could not find any statement corresponding to th
horo 2014/09/04 11:55:15 RFC7231 says...
278 RefPtr<BlobDataHandle> blobDataHandle = m_request->blobDataHandle();
279 if (blobDataHandle.get()) {
280 RefPtr<FormData> httpBody(FormData::create());
281 httpBody->appendBlob(blobDataHandle->uuid(), blobDataHandle);
282 request.setHTTPBody(httpBody);
283 }
284 }
285
276 // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer| 286 // "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer|
277 // is none, and `Referer`/|HTTPRequest|'s referrer, serialized and utf-8 287 // is none, and `Referer`/|HTTPRequest|'s referrer, serialized and utf-8
278 // encoded, otherwise, to HTTPRequest's header list. 288 // encoded, otherwise, to HTTPRequest's header list.
279 // We set the referrer using workerGlobalScope's URL in 289 // We set the referrer using workerGlobalScope's URL in
280 // WorkerThreadableLoader. 290 // WorkerThreadableLoader.
281 291
282 // "3. Append `Host`, ..." 292 // "3. Append `Host`, ..."
283 // FIXME: Implement this when the spec is fixed. 293 // FIXME: Implement this when the spec is fixed.
284 294
285 // "4.If |HTTPRequest|'s force Origin header flag is set, append `Origin`/ 295 // "4.If |HTTPRequest|'s force Origin header flag is set, append `Origin`/
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 loader->start(); 361 loader->start();
352 return promise; 362 return promise;
353 } 363 }
354 364
355 void FetchManager::onLoaderFinished(Loader* loader) 365 void FetchManager::onLoaderFinished(Loader* loader)
356 { 366 {
357 m_loaders.remove(loader); 367 m_loaders.remove(loader);
358 } 368 }
359 369
360 } // namespace blink 370 } // namespace blink
OLDNEW
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/request-worker.js ('k') | Source/modules/serviceworkers/FetchRequestData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698