diff --git a/v2/background/src/debuggee.ts b/v2/background/src/debuggee.ts index 6e44c44..1683445 100644 --- a/v2/background/src/debuggee.ts +++ b/v2/background/src/debuggee.ts @@ -105,7 +105,12 @@ export class Debuggee { }): Promise; async sendCommand(method: 'Fetch.enable', params: { patterns: Debugger_Fetch_RequestPattern[] }): Promise; async sendCommand(method: 'Fetch.getResponseBody', params: { requestId: string }): Promise; - async sendCommand(method: 'Fetch.continueRequest', params: { requestId: string } & Partial): Promise; + async sendCommand(method: 'Fetch.continueRequest', params: { requestId: string} & Partial<{ + url: string, + method: string, + postData: string, + headers: Debugger_Fetch_HeaderEntry[] + }>): Promise; async sendCommand(method: 'Fetch.fulfillRequest', params: { requestId: string, responseCode: number, diff --git a/v2/background/src/request.ts b/v2/background/src/request.ts index e583923..5c3db6c 100644 --- a/v2/background/src/request.ts +++ b/v2/background/src/request.ts @@ -14,10 +14,10 @@ export abstract class Intercepted implements InterceptedData { id: string; method: string; url: string; - requestHeaders: { name: string, value: string }[]; + requestHeaders: Debugger_Fetch_HeaderEntry[]; requestBody?: string | null; status?: number; - responseHeaders?: { name: string, value: string }[]; + responseHeaders?: Debugger_Fetch_HeaderEntry[]; responseBody?: string | null = null; protected constructor(dbg: Debuggee, { id, method, url, requestHeaders, requestBody, status, responseHeaders }: InterceptedData) { @@ -105,20 +105,33 @@ export class FetchIntercepted extends Intercepted { id: requestId, method: request.method, url: request.url, - requestHeaders: Object.entries(request.headers).map(e => ({ name: e[0], value: e[1] })), + requestHeaders: FetchIntercepted.convertHeaders(request.headers), requestBody: request.hasPostData ? request.postData : null, status: responseStatusCode, responseHeaders: responseHeaders, }); } + private static convertHeaders(headers: Record|undefined): Debugger_Fetch_HeaderEntry[] { + return Object.entries(headers||{}).map(e => ({ name: e[0], value: e[1] })); + } + async getResponseBodyInternal() { return this.debuggee.sendCommand('Fetch.getResponseBody', { requestId: this.id }); } async continueRequestInternal(request: Partial) { + if (JSON.stringify(request) == '{}') { + return this.debuggee.sendCommand( + 'Fetch.continueRequest', { requestId: this.id }); + } return this.debuggee.sendCommand( - 'Fetch.continueRequest', Object.assign({ requestId: this.id }, request)); + 'Fetch.continueRequest', { + requestId: this.id, + method: request.method, + url: request.url, + headers: FetchIntercepted.convertHeaders(request.headers) + }); } async continueResponseInternal(response: Partial) {