chore(route): wait for raw headers from browser in case of redirects (#31410)

Redirects are always autoresumed, so the will always receive extra info
with raw headers. We only want to make raw headers available immediately
when there is a route.

Reference https://github.com/microsoft/playwright/issues/31351
This commit is contained in:
Yury Semikhatsky 2024-06-24 12:25:12 -07:00 committed by GitHub
parent de723f39e9
commit 2b12f53332
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -359,11 +359,11 @@ export class CRNetworkManager {
});
this._requestIdToRequest.set(requestWillBeSentEvent.requestId, request);
if (requestPausedEvent) {
// We will not receive extra info when intercepting the request.
if (route) {
// We may not receive extra info when intercepting the request.
// Use the headers from the Fetch.requestPausedPayload and release the allHeaders()
// right away, so that client can call it from the route handler.
request.request.setRawRequestHeaders(headersOverride ?? headersObjectToArray(requestPausedEvent.request.headers, '\n'));
request.request.setRawRequestHeaders(headersObjectToArray(requestPausedEvent!.request.headers, '\n'));
}
(this._page?._frameManager || this._serviceWorker)!.requestStarted(request.request, route || undefined);
}