browser(webkit): fix intercepting with a redirect (#1787)

This commit is contained in:
Joel Einbinder 2020-04-15 11:17:33 -07:00 committed by GitHub
parent 60eb3cdd3d
commit 762dfe1a59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 11 deletions

View file

@ -1 +1 @@
1195 1196

View file

@ -2666,7 +2666,7 @@ index b578660fbb3ce176e4e0aeb5a22021dc880e47f0..a7c968bc9f88c7d26e1887bb53106b4a
class Page; class Page;
class SecurityOrigin; class SecurityOrigin;
diff --git a/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp b/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp diff --git a/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp b/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
index ee9edb30dd7b3461c4d491dfaf7929011d498bc9..71b51b0261494112b23800fe02f5e31bb90769bb 100644 index ee9edb30dd7b3461c4d491dfaf7929011d498bc9..53872c5dc1487e08cdc2a14ef0738ad0499cb1b6 100644
--- a/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp --- a/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
+++ b/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp +++ b/Source/WebCore/inspector/agents/InspectorNetworkAgent.cpp
@@ -44,6 +44,7 @@ @@ -44,6 +44,7 @@
@ -2758,7 +2758,7 @@ index ee9edb30dd7b3461c4d491dfaf7929011d498bc9..71b51b0261494112b23800fe02f5e31b
} }
void InspectorNetworkAgent::addInterception(ErrorString& errorString, const String& url, const bool* optionalCaseSensitive, const bool* optionalIsRegex, const String* networkStageString) void InspectorNetworkAgent::addInterception(ErrorString& errorString, const String& url, const bool* optionalCaseSensitive, const bool* optionalIsRegex, const String* networkStageString)
@@ -1112,19 +1135,128 @@ void InspectorNetworkAgent::interceptResponse(const ResourceResponse& response, @@ -1112,19 +1135,133 @@ void InspectorNetworkAgent::interceptResponse(const ResourceResponse& response,
m_frontendDispatcher->responseIntercepted(requestId, buildObjectForResourceResponse(response, nullptr)); m_frontendDispatcher->responseIntercepted(requestId, buildObjectForResourceResponse(response, nullptr));
} }
@ -2881,19 +2881,24 @@ index ee9edb30dd7b3461c4d491dfaf7929011d498bc9..71b51b0261494112b23800fe02f5e31b
+ } + }
+ response.setHTTPHeaderFields(WTFMove(explicitHeaders)); + response.setHTTPHeaderFields(WTFMove(explicitHeaders));
+ response.setHTTPHeaderField(HTTPHeaderName::ContentType, response.mimeType()); + response.setHTTPHeaderField(HTTPHeaderName::ContentType, response.mimeType());
+ loader->didReceiveResponse(response, [loader, data = data.releaseNonNull()]() mutable { + if (response.isRedirection()) {
+ if (data->size()) + loader->setRequest(loader->request().redirectedRequest(response, false));
+ loader->didReceiveBuffer(WTFMove(data), data->size(), DataPayloadWholeResource); + pendingRequest->m_callback(false);
+ loader->didFinishLoading(NetworkLoadMetrics()); + } else {
+ }); + loader->didReceiveResponse(response, [loader, data = data.releaseNonNull()]() mutable {
+ pendingRequest->m_callback(true); + if (data->size())
+ loader->didReceiveBuffer(WTFMove(data), data->size(), DataPayloadWholeResource);
+ loader->didFinishLoading(NetworkLoadMetrics());
+ });
+ pendingRequest->m_callback(true);
+ }
+ return; + return;
+ } + }
+ +
auto pendingInterceptResponse = m_pendingInterceptResponses.take(requestId); auto pendingInterceptResponse = m_pendingInterceptResponses.take(requestId);
if (!pendingInterceptResponse) { if (!pendingInterceptResponse) {
errorString = "Missing pending intercept response for given requestId"_s; errorString = "Missing pending intercept response for given requestId"_s;
@@ -1152,20 +1284,26 @@ void InspectorNetworkAgent::interceptWithResponse(ErrorString& errorString, cons @@ -1152,20 +1289,26 @@ void InspectorNetworkAgent::interceptWithResponse(ErrorString& errorString, cons
} }
RefPtr<SharedBuffer> overrideData; RefPtr<SharedBuffer> overrideData;
@ -2924,7 +2929,7 @@ index ee9edb30dd7b3461c4d491dfaf7929011d498bc9..71b51b0261494112b23800fe02f5e31b
bool InspectorNetworkAgent::shouldTreatAsText(const String& mimeType) bool InspectorNetworkAgent::shouldTreatAsText(const String& mimeType)
{ {
return startsWithLettersIgnoringASCIICase(mimeType, "text/") return startsWithLettersIgnoringASCIICase(mimeType, "text/")
@@ -1295,6 +1433,11 @@ void InspectorNetworkAgent::searchInRequest(ErrorString& errorString, const Stri @@ -1295,6 +1438,11 @@ void InspectorNetworkAgent::searchInRequest(ErrorString& errorString, const Stri
results = ContentSearchUtilities::searchInTextByLines(resourceData->content(), query, caseSensitive, isRegex); results = ContentSearchUtilities::searchInTextByLines(resourceData->content(), query, caseSensitive, isRegex);
} }