diff --git a/src/bidiMapper/domains/network/NetworkProcessor.ts b/src/bidiMapper/domains/network/NetworkProcessor.ts index c4b762e25a..a808b83303 100644 --- a/src/bidiMapper/domains/network/NetworkProcessor.ts +++ b/src/bidiMapper/domains/network/NetworkProcessor.ts @@ -74,7 +74,13 @@ export class NetworkProcessor { async continueRequest( params: Network.ContinueRequestParameters ): Promise { - const {url, method, headers, request: networkId} = params; + const { + url, + method, + headers: commandHeaders, + body, + request: networkId, + } = params; if (params.url !== undefined) { NetworkProcessor.parseUrlString(params.url); @@ -84,13 +90,17 @@ export class NetworkProcessor { Network.InterceptPhase.BeforeRequestSent, ]); - const requestHeaders: Protocol.Fetch.HeaderEntry[] | undefined = - cdpFetchHeadersFromBidiNetworkHeaders(headers); + const headers: Protocol.Fetch.HeaderEntry[] | undefined = + cdpFetchHeadersFromBidiNetworkHeaders(commandHeaders); // TODO: Set / expand. // ; Step 9. cookies - // ; Step 10. body - await request.continueRequest(url, method, requestHeaders); + await request.continueRequest({ + url, + method, + headers, + postData: getCdpBodyFromBiDiBytesValue(body), + }); return {}; } @@ -238,18 +248,11 @@ export class NetworkProcessor { const responseCode = statusCode ?? request.statusCode ?? 200; - let parsedBody: string | undefined; - if (body?.type === 'string') { - parsedBody = btoa(body.value); - } else if (body?.type === 'base64') { - parsedBody = body.value; - } - await request.provideResponse({ responseCode, responsePhrase, responseHeaders, - body: parsedBody, + body: getCdpBodyFromBiDiBytesValue(body), }); return {}; @@ -435,3 +438,15 @@ function unescapeURLPattern(pattern: string) { } return result; } + +function getCdpBodyFromBiDiBytesValue( + body?: Network.BytesValue +): string | undefined { + let parsedBody: string | undefined; + if (body?.type === 'string') { + parsedBody = btoa(body.value); + } else if (body?.type === 'base64') { + parsedBody = body.value; + } + return parsedBody; +} diff --git a/src/bidiMapper/domains/network/NetworkRequest.ts b/src/bidiMapper/domains/network/NetworkRequest.ts index cf3f3b264a..f923080150 100644 --- a/src/bidiMapper/domains/network/NetworkRequest.ts +++ b/src/bidiMapper/domains/network/NetworkRequest.ts @@ -381,11 +381,12 @@ export class NetworkRequest { } /** @see https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#method-continueRequest */ - async continueRequest( - url?: string, - method?: string, - headers?: Protocol.Fetch.HeaderEntry[] - ) { + async continueRequest({ + url, + method, + headers, + postData, + }: Omit = {}) { assert(this.#fetchId, 'Network Interception not set-up.'); await this.cdpClient.sendCommand('Fetch.continueRequest', { @@ -393,9 +394,7 @@ export class NetworkRequest { url, method, headers, - // TODO: Set? - // postData:, - // interceptResponse:, + postData, }); this.#interceptPhase = undefined; } @@ -541,6 +540,7 @@ export class NetworkRequest { this.#response.info?.headers ); + // TODO: get headers from Fetch.requestPaused const authChallenges = this.#authChallenges( this.#response.info?.headers ?? {} );