Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async createResponse(cdpResponse: Crdp.Network.ResponseReceivedEvent, element: IAsyncHTMLElement): Promise {
const resourceUrl: string = cdpResponse.response.url;
const hops: Array = this._redirects.calculate(resourceUrl);
const resourceHeaders: object = normalizeHeaders(cdpResponse.response.headers);
let { content, rawContent, rawResponse } = await this.getResponseBody(cdpResponse);
let retry = 3;
/*
* Sometimes, the content is empty at the beginning, but
* after few millisecons, it isn't.
*/
while (!content && (!rawContent || rawContent.length === 0) && retry > 0) {
await delay(250);
({ content, rawContent, rawResponse } = await this.getResponseBody(cdpResponse));
retry--;
}
if (retry === 0) {