MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / rawHttpGet

Function rawHttpGet

packages/server/test/host-exposure.e2e.test.ts:231–256  ·  view source on GitHub ↗

* Raw HTTP GET that lets us set an arbitrary `Host` header. Node's `fetch` * (undici) treats `Host` as a forbidden header and silently replaces it with * the URL host, so the Host-allowlist test drives `node:http` directly.

(
  url: string,
  headers: Record<string, string>,
)

Source from the content-addressed store, hash-verified

229 * the URL host, so the Host-allowlist test drives `node:http` directly.
230 */
231function rawHttpGet(
232 url: string,
233 headers: Record<string, string>,
234): Promise<{ status: number; body: string }> {
235 return new Promise((resolve, reject) => {
236 const u = new URL(url);
237 const req = httpRequest(
238 {
239 hostname: u.hostname,
240 port: u.port,
241 path: `${u.pathname}${u.search}`,
242 method: 'GET',
243 headers,
244 },
245 (res) => {
246 let body = '';
247 res.on('data', (chunk: Buffer) => {
248 body += chunk.toString();
249 });
250 res.on('end', () => resolve({ status: res.statusCode ?? 0, body }));
251 },
252 );
253 req.on('error', reject);
254 req.end();
255 });
256}
257
258describe('public-bind §3.5 end-to-end (M6.7)', () => {
259 /**

Callers 1

Calls 4

onMethod · 0.65
toStringMethod · 0.65
resolveFunction · 0.50
endMethod · 0.45

Tested by

no test coverage detected