MCPcopy Index your code
hub / github.com/nodejs/node / httpGet

Method httpGet

test/common/inspector-helper.js:416–438  ·  view source on GitHub ↗
(host, path, hostHeaderValue)

Source from the content-addressed store, hash-verified

414 }
415
416 httpGet(host, path, hostHeaderValue) {
417 this._logger.log('[test]', `Testing ${path}`);
418 const headers = hostHeaderValue ? { 'Host': hostHeaderValue } : null;
419 return this.portPromise.then((port) => new Promise((resolve, reject) => {
420 const req = http.get({ host, port, family: 4, path, headers }, (res) => {
421 let response = '';
422 res.setEncoding('utf8');
423 res
424 .on('data', (data) => response += data.toString())
425 .on('end', () => {
426 resolve(response);
427 });
428 });
429 req.on('error', reject);
430 })).then((response) => {
431 try {
432 return JSON.parse(response);
433 } catch (e) {
434 e.body = response;
435 throw e;
436 }
437 });
438 }
439
440 async sendUpgradeRequest() {
441 const response = await this.httpGet(null, '/json/list');

Callers 5

sendUpgradeRequestMethod · 0.95
testFunction · 0.95
runTestFunction · 0.95
testFunction · 0.95
testHttpFunction · 0.80

Calls 8

resolveFunction · 0.70
getMethod · 0.65
parseMethod · 0.65
logMethod · 0.45
thenMethod · 0.45
setEncodingMethod · 0.45
onMethod · 0.45
toStringMethod · 0.45

Tested by 2

testFunction · 0.76
testFunction · 0.76