MCPcopy
hub / github.com/microsoft/playwright / fetchData

Function fetchData

packages/playwright-core/src/server/utils.ts:24–45  ·  view source on GitHub ↗
(progress: Progress | undefined, params: HTTPRequestParams, onError?: (params: HTTPRequestParams, response: http.IncomingMessage) => Promise<Error>)

Source from the content-addressed store, hash-verified

22import type { Progress } from './progress';
23
24export async function fetchData(progress: Progress | undefined, params: HTTPRequestParams, onError?: (params: HTTPRequestParams, response: http.IncomingMessage) => Promise<Error>): Promise<string> {
25 const promise = new ManualPromise<string>();
26 const { cancel } = httpRequest(params, async response => {
27 if (response.statusCode !== 200) {
28 const error = onError ? await onError(params, response) : new Error(`fetch failed: server returned code ${response.statusCode}. URL: ${params.url}`);
29 promise.reject(error);
30 return;
31 }
32 let body = '';
33 response.on('data', (chunk: string) => body += chunk);
34 response.on('error', (error: any) => promise.reject(error));
35 response.on('end', () => promise.resolve(body));
36 }, error => promise.reject(error));
37 if (!progress)
38 return promise;
39 try {
40 return await progress.race(promise);
41 } catch (error) {
42 cancel(error);
43 throw error;
44 }
45}

Callers 5

urlToWSEndpointFunction · 0.90
_installMSEdgeChannelMethod · 0.90
launchWithSeleniumHubMethod · 0.90
urlToWSEndpointFunction · 0.90

Calls 6

rejectMethod · 0.95
resolveMethod · 0.95
httpRequestFunction · 0.90
onMethod · 0.65
raceMethod · 0.65
onErrorFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…