MCPcopy Index your code
hub / github.com/microsoft/playwright / httpStatusCode

Function httpStatusCode

packages/utils/network.ts:209–228  ·  view source on GitHub ↗
(url: URL, ignoreHTTPSErrors: boolean, onLog?: (data: string) => void, onStdErr?: (data: string) => void)

Source from the content-addressed store, hash-verified

207}
208
209async function httpStatusCode(url: URL, ignoreHTTPSErrors: boolean, onLog?: (data: string) => void, onStdErr?: (data: string) => void): Promise<number> {
210 return new Promise(resolve => {
211 onLog?.(`HTTP GET: ${url}`);
212 httpRequest({
213 url: url.toString(),
214 headers: { Accept: '*/*' },
215 rejectUnauthorized: !ignoreHTTPSErrors
216 }, res => {
217 res.resume();
218 const statusCode = res.statusCode ?? 0;
219 onLog?.(`HTTP Status: ${statusCode}`);
220 resolve(statusCode);
221 }, error => {
222 if ((error as NodeJS.ErrnoException).code === 'DEPTH_ZERO_SELF_SIGNED_CERT')
223 onStdErr?.(`[WebServer] Self-signed certificate detected. Try adding ignoreHTTPSErrors: true to config.webServer.`);
224 onLog?.(`Error while checking if ${url} is available: ${error.message}`);
225 resolve(0);
226 });
227 });
228}
229
230export function decorateServer(server: net.Server) {
231 const sockets = new Set<net.Socket>();

Callers 1

isURLAvailableFunction · 0.85

Calls 4

httpRequestFunction · 0.85
toStringMethod · 0.65
resumeMethod · 0.65
resolveFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…