Title: [220366] trunk/Source/WebCore
- Revision
- 220366
- Author
- [email protected]
- Date
- 2017-08-07 16:22:11 -0700 (Mon, 07 Aug 2017)
Log Message
Update sendBeacon() to rely on FetchBody instead of the whole FetchRequest
https://bugs.webkit.org/show_bug.cgi?id=175280
Reviewed by Youenn Fablet.
Update sendBeacon() to rely on FetchBody instead of the whole FetchRequest. FetchBody
for data extraction is really the only thing we need at the moment.
The new code also properly sets the CORS mode, which will be needed for Bug 175264.
* Modules/beacon/NavigatorBeacon.cpp:
(WebCore::NavigatorBeacon::sendBeacon):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (220365 => 220366)
--- trunk/Source/WebCore/ChangeLog 2017-08-07 23:18:31 UTC (rev 220365)
+++ trunk/Source/WebCore/ChangeLog 2017-08-07 23:22:11 UTC (rev 220366)
@@ -1,3 +1,17 @@
+2017-08-07 Chris Dumez <[email protected]>
+
+ Update sendBeacon() to rely on FetchBody instead of the whole FetchRequest
+ https://bugs.webkit.org/show_bug.cgi?id=175280
+
+ Reviewed by Youenn Fablet.
+
+ Update sendBeacon() to rely on FetchBody instead of the whole FetchRequest. FetchBody
+ for data extraction is really the only thing we need at the moment.
+ The new code also properly sets the CORS mode, which will be needed for Bug 175264.
+
+ * Modules/beacon/NavigatorBeacon.cpp:
+ (WebCore::NavigatorBeacon::sendBeacon):
+
2017-08-07 Michael Catanzaro <[email protected]>
-Wimplicit-fallthrough warning in ComputedStyleExtractor::propertyValue
Modified: trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp (220365 => 220366)
--- trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2017-08-07 23:18:31 UTC (rev 220365)
+++ trunk/Source/WebCore/Modules/beacon/NavigatorBeacon.cpp 2017-08-07 23:22:11 UTC (rev 220366)
@@ -28,10 +28,10 @@
#include "CachedResourceLoader.h"
#include "Document.h"
-#include "FetchRequest.h"
+#include "FetchBody.h"
+#include "HTTPParsers.h"
#include "Navigator.h"
#include "URL.h"
-#include <runtime/JSCJSValue.h>
namespace WebCore {
@@ -55,21 +55,25 @@
return true;
}
- FetchRequestInit init;
- init.method = ASCIILiteral("POST");
- init.body = WTFMove(body);
- init.credentials = FetchOptions::Credentials::Include;
- init.cache = FetchOptions::Cache::NoCache;
- init.redirect = FetchOptions::Redirect::Follow;
- init.keepalive = true;
- init.window = JSC::jsNull();
+ ResourceRequest request(parsedUrl);
+ request.setHTTPMethod(ASCIILiteral("POST"));
- auto fetchRequestResult = FetchRequest::create(document, parsedUrl.string(), WTFMove(init));
- if (fetchRequestResult.hasException())
- return fetchRequestResult.releaseException();
-
- auto fetchRequest = fetchRequestResult.releaseReturnValue();
- document.cachedResourceLoader().requestBeaconResource({ fetchRequest->internalRequest(), fetchRequest->fetchOptions() });
+ FetchOptions options;
+ options.credentials = FetchOptions::Credentials::Include;
+ options.cache = FetchOptions::Cache::NoCache;
+ options.keepAlive = true;
+ if (body) {
+ options.mode = FetchOptions::Mode::Cors;
+ String mimeType;
+ auto fetchBody = FetchBody::extract(document, WTFMove(body.value()), mimeType);
+ request.setHTTPBody(fetchBody.bodyForInternalRequest(document));
+ if (!mimeType.isEmpty()) {
+ request.setHTTPContentType(mimeType);
+ if (isCrossOriginSafeRequestHeader(HTTPHeaderName::ContentType, mimeType))
+ options.mode = FetchOptions::Mode::NoCors;
+ }
+ }
+ document.cachedResourceLoader().requestBeaconResource({ WTFMove(request), options });
return true;
}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes