MCPcopy Create free account
hub / github.com/11ty/dev-server / makeRequestTo

Function makeRequestTo

test/testServerRequests.js:15–44  ·  view source on GitHub ↗
(t, server, path)

Source from the content-addressed store, hash-verified

13}
14
15async function makeRequestTo(t, server, path) {
16 let port = await server.getPort();
17
18 return new Promise(resolve => {
19 const options = {
20 hostname: 'localhost',
21 port,
22 path,
23 method: 'GET',
24 };
25
26 http.get(options, (res) => {
27 const { statusCode } = res;
28 if(statusCode !== 200) {
29 throw new Error("Invalid status code" + statusCode);
30 }
31
32 res.setEncoding('utf8');
33
34 let rawData = '';
35 res.on('data', (chunk) => { rawData += chunk; });
36 res.on('end', () => {
37 t.true( true );
38 resolve(rawData);
39 });
40 }).on('error', (e) => {
41 console.error(`Got error: ${e.message}`);
42 });
43 })
44}
45
46async function fetchHeadersForRequest(t, server, path, extras) {
47 let port = await server.getPort();

Callers 1

Calls 2

getPortMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…