Skip to content

Commit 0039b31

Browse files
authored
browser(webkit): support downloads larger than 16Kb on Windows (#6343)
1 parent 3413574 commit 0039b31

File tree

2 files changed

+58
-17
lines changed

2 files changed

+58
-17
lines changed

browser_patches/webkit/BUILD_NUMBER

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
1467
2-
Changed: [email protected] Mon 26 Apr 2021 04:14:04 PM PDT
1+
1468
2+
Changed: [email protected] Tue, Apr 27, 2021 10:33:49 PM

browser_patches/webkit/patches/bootstrap.diff

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8394,7 +8394,7 @@ index 88abe8c29c43b8c8881d29e25a21e4dd370ab498..c5e3439a0ce52a9d368b984c7849fac7
83948394
#if !LOG_DISABLED
83958395
LOG(NetworkSession, "%llu didReceiveResponse completionHandler (%d)", taskIdentifier, policyAction);
83968396
diff --git a/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp b/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
8397-
index e9fdf357d64f8916b35e5e00469b997580db3abd..32135740fb58e7ca124a4fdc8514ebfc2e0712de 100644
8397+
index e9fdf357d64f8916b35e5e00469b997580db3abd..7f44429cde3a8d2e44b47d3f65549b76a24ed38a 100644
83988398
--- a/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
83998399
+++ b/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.cpp
84008400
@@ -26,9 +26,13 @@
@@ -8428,46 +8428,69 @@ index e9fdf357d64f8916b35e5e00469b997580db3abd..32135740fb58e7ca124a4fdc8514ebfc
84288428
m_curlRequest->setStartTime(m_startTime);
84298429
m_curlRequest->start();
84308430
}
8431-
@@ -153,6 +160,7 @@ void NetworkDataTaskCurl::curlDidReceiveResponse(CurlRequest& request, CurlRespo
8431+
@@ -109,6 +116,9 @@ void NetworkDataTaskCurl::cancel()
8432+
8433+
if (m_curlRequest)
8434+
m_curlRequest->cancel();
8435+
+
8436+
+ if (isDownload())
8437+
+ deleteDownloadFile();
8438+
}
8439+
8440+
void NetworkDataTaskCurl::invalidateAndCancel()
8441+
@@ -153,6 +163,7 @@ void NetworkDataTaskCurl::curlDidReceiveResponse(CurlRequest& request, CurlRespo
84328442
m_response = ResourceResponse(receivedResponse);
84338443
m_response.setCertificateInfo(WTFMove(receivedResponse.certificateInfo));
84348444
m_response.setDeprecatedNetworkLoadMetrics(Box<NetworkLoadMetrics>::create(WTFMove(receivedResponse.networkLoadMetrics)));
84358445
+ m_response.m_httpRequestHeaderFields = request.resourceRequest().httpHeaderFields();
84368446

84378447
handleCookieHeaders(request.resourceRequest(), receivedResponse);
84388448

8439-
@@ -180,7 +188,12 @@ void NetworkDataTaskCurl::curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&&
8449+
@@ -180,7 +191,10 @@ void NetworkDataTaskCurl::curlDidReceiveBuffer(CurlRequest&, Ref<SharedBuffer>&&
84408450
auto protectedThis = makeRef(*this);
84418451
if (state() == State::Canceling || state() == State::Completed || (!m_client && !isDownload()))
84428452
return;
84438453
-
84448454
+ if (isDownload()) {
8445-
+ FileSystem::PlatformFileHandle file = FileSystem::openFile(m_pendingDownloadLocation, FileSystem::FileOpenMode::Write);
8446-
+ FileSystem::writeToFile(file, buffer->data(), buffer->size());
8447-
+ FileSystem::closeFile(file);
8455+
+ FileSystem::writeToFile(m_downloadDestinationFile, buffer->data(), buffer->size());
84488456
+ return;
84498457
+ }
84508458
m_client->didReceiveData(WTFMove(buffer));
84518459
}
84528460

8453-
@@ -189,6 +202,12 @@ void NetworkDataTaskCurl::curlDidComplete(CurlRequest&, NetworkLoadMetrics&& net
8461+
@@ -189,9 +203,26 @@ void NetworkDataTaskCurl::curlDidComplete(CurlRequest&, NetworkLoadMetrics&& net
84548462
if (state() == State::Canceling || state() == State::Completed || (!m_client && !isDownload()))
84558463
return;
84568464

84578465
+ if (isDownload()) {
84588466
+ auto* download = m_session->networkProcess().downloadManager().download(m_pendingDownloadID);
84598467
+ ASSERT(download);
8468+
+ FileSystem::closeFile(m_downloadDestinationFile);
8469+
+ m_downloadDestinationFile = FileSystem::invalidPlatformFileHandle;
84608470
+ download->didFinish();
84618471
+ return;
84628472
+ }
84638473
m_client->didCompleteWithError({ }, WTFMove(networkLoadMetrics));
84648474
}
84658475

8466-
@@ -202,6 +221,13 @@ void NetworkDataTaskCurl::curlDidFailWithError(CurlRequest& request, ResourceErr
8476+
+void NetworkDataTaskCurl::deleteDownloadFile()
8477+
+{
8478+
+ if (m_downloadDestinationFile != FileSystem::invalidPlatformFileHandle) {
8479+
+ FileSystem::closeFile(m_downloadDestinationFile);
8480+
+ FileSystem::deleteFile(m_pendingDownloadLocation);
8481+
+ m_downloadDestinationFile = FileSystem::invalidPlatformFileHandle;
8482+
+ }
8483+
+}
8484+
+
8485+
void NetworkDataTaskCurl::curlDidFailWithError(CurlRequest& request, ResourceError&& resourceError, CertificateInfo&& certificateInfo)
8486+
{
8487+
if (state() == State::Canceling || state() == State::Completed || (!m_client && !isDownload()))
8488+
@@ -202,6 +233,14 @@ void NetworkDataTaskCurl::curlDidFailWithError(CurlRequest& request, ResourceErr
84678489
return;
84688490
}
84698491

84708492
+ if (isDownload()) {
8493+
+ deleteDownloadFile();
84718494
+ auto* download = m_session->networkProcess().downloadManager().download(m_pendingDownloadID);
84728495
+ ASSERT(download);
84738496
+ download->didFail(resourceError, IPC::DataReference());
@@ -8477,7 +8500,7 @@ index e9fdf357d64f8916b35e5e00469b997580db3abd..32135740fb58e7ca124a4fdc8514ebfc
84778500
m_client->didCompleteWithError(resourceError);
84788501
}
84798502

8480-
@@ -239,6 +265,18 @@ void NetworkDataTaskCurl::invokeDidReceiveResponse()
8503+
@@ -239,6 +278,19 @@ void NetworkDataTaskCurl::invokeDidReceiveResponse()
84818504
case PolicyAction::Ignore:
84828505
invalidateAndCancel();
84838506
break;
@@ -8487,6 +8510,7 @@ index e9fdf357d64f8916b35e5e00469b997580db3abd..32135740fb58e7ca124a4fdc8514ebfc
84878510
+ auto download = makeUnique<Download>(downloadManager, m_pendingDownloadID, *this, *m_session, suggestedFilename());
84888511
+ auto* downloadPtr = download.get();
84898512
+ downloadManager.dataTaskBecameDownloadTask(m_pendingDownloadID, WTFMove(download));
8513+
+ m_downloadDestinationFile = FileSystem::openFile(m_pendingDownloadLocation, FileSystem::FileOpenMode::Write);
84908514
+ downloadPtr->didCreateDestination(m_pendingDownloadLocation);
84918515
+
84928516
+ if (m_curlRequest)
@@ -8496,7 +8520,7 @@ index e9fdf357d64f8916b35e5e00469b997580db3abd..32135740fb58e7ca124a4fdc8514ebfc
84968520
default:
84978521
notImplemented();
84988522
break;
8499-
@@ -321,6 +359,8 @@ void NetworkDataTaskCurl::willPerformHTTPRedirection()
8523+
@@ -321,6 +373,8 @@ void NetworkDataTaskCurl::willPerformHTTPRedirection()
85008524
m_curlRequest->setUserPass(m_initialCredential.user(), m_initialCredential.password());
85018525
m_curlRequest->setAuthenticationScheme(ProtectionSpaceAuthenticationSchemeHTTPBasic);
85028526
}
@@ -8506,10 +8530,18 @@ index e9fdf357d64f8916b35e5e00469b997580db3abd..32135740fb58e7ca124a4fdc8514ebfc
85068530
m_curlRequest->start();
85078531

85088532
diff --git a/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h b/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h
8509-
index 46c215a99a9bb31546e8880ce6f0876193c075fe..3509c62ac2c970fdcf78db2503c0cc4259f56dbd 100644
8533+
index 46c215a99a9bb31546e8880ce6f0876193c075fe..82c3afd36a91962c540e69d176c086b98e80ddc1 100644
85108534
--- a/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h
85118535
+++ b/Source/WebKit/NetworkProcess/curl/NetworkDataTaskCurl.h
8512-
@@ -85,14 +85,13 @@ private:
8536+
@@ -32,6 +32,7 @@
8537+
#include <WebCore/ProtectionSpace.h>
8538+
#include <WebCore/ResourceResponse.h>
8539+
#include <WebCore/ShouldRelaxThirdPartyCookieBlocking.h>
8540+
+#include <wtf/FileSystem.h>
8541+
#include <wtf/MonotonicTime.h>
8542+
8543+
namespace WebCore {
8544+
@@ -85,13 +86,13 @@ private:
85138545

85148546
void appendCookieHeader(WebCore::ResourceRequest&);
85158547
void handleCookieHeaders(const WebCore::ResourceRequest&, const WebCore::CurlResponse&);
@@ -8519,12 +8551,21 @@ index 46c215a99a9bb31546e8880ce6f0876193c075fe..3509c62ac2c970fdcf78db2503c0cc42
85198551
bool shouldBlockCookies(const WebCore::ResourceRequest&);
85208552
void blockCookies();
85218553
void unblockCookies();
8522-
8523-
- String suggestedFilename() const override;
85248554
-
8555+
- String suggestedFilename() const override;
8556+
+ void deleteDownloadFile();
8557+
85258558
State m_state { State::Suspended };
85268559

8527-
RefPtr<WebCore::CurlRequest> m_curlRequest;
8560+
@@ -104,6 +105,8 @@ private:
8561+
WebCore::FrameIdentifier m_frameID;
8562+
WebCore::PageIdentifier m_pageID;
8563+
8564+
+ FileSystem::PlatformFileHandle m_downloadDestinationFile { FileSystem::invalidPlatformFileHandle };
8565+
+
8566+
bool m_blockingCookies { false };
8567+
8568+
WebCore::ShouldRelaxThirdPartyCookieBlocking m_shouldRelaxThirdPartyCookieBlocking { WebCore::ShouldRelaxThirdPartyCookieBlocking::No };
85288569
diff --git a/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp b/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp
85298570
index 0d690beb77a8d299b6e0137ac3f21d40eff2f2d9..25a05f893cb10aaeaaf17c7c27bd2a1e61abe384 100644
85308571
--- a/Source/WebKit/NetworkProcess/soup/NetworkDataTaskSoup.cpp

0 commit comments

Comments
 (0)