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

Unified 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: move tests to fetch-worker.js 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/serviceworkers/FetchManager.cpp
diff --git a/Source/modules/serviceworkers/FetchManager.cpp b/Source/modules/serviceworkers/FetchManager.cpp
index 3cbd4b5bc3128793e454850f1b721520ea0ff00a..03f5c33f0ebc552b09ff19473ceb0039003967f4 100644
--- a/Source/modules/serviceworkers/FetchManager.cpp
+++ b/Source/modules/serviceworkers/FetchManager.cpp
@@ -258,6 +258,7 @@ void FetchManager::Loader::performNetworkError()
void FetchManager::Loader::performHTTPFetch()
{
+ ASSERT(m_request->url().protocolIsInHTTPFamily());
// CORS preflight fetch procedure is implemented inside DocumentThreadableLoader.
// "1. Let |HTTPRequest| be a copy of |request|, except that |HTTPRequest|'s
@@ -273,6 +274,15 @@ void FetchManager::Loader::performHTTPFetch()
request.addHTTPHeaderField(AtomicString(list[i]->first), AtomicString(list[i]->second));
}
+ if (m_request->method() != "GET" && m_request->method() != "HEAD") {
+ RefPtr<BlobDataHandle> blobDataHandle = m_request->blobDataHandle();
+ if (blobDataHandle.get()) {
+ RefPtr<FormData> httpBody(FormData::create());
+ httpBody->appendBlob(blobDataHandle->uuid(), blobDataHandle);
+ request.setHTTPBody(httpBody);
+ }
+ }
+
// "2. Append `Referer`/empty byte sequence, if |HTTPRequest|'s |referrer|
// is none, and `Referer`/|HTTPRequest|'s referrer, serialized and utf-8
// encoded, otherwise, to HTTPRequest's header list.
« no previous file with comments | « LayoutTests/http/tests/serviceworker/resources/fetch-worker.js ('k') | Source/modules/serviceworkers/FetchRequestData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698