MCPcopy Create free account
hub / github.com/callstack/agent-device / buildUpstreamHeaders

Function buildUpstreamHeaders

src/remote/daemon-proxy.ts:312–329  ·  view source on GitHub ↗
(
  req: Pick<IncomingMessage, 'headers'>,
  upstreamToken: string,
  route: string,
)

Source from the content-addressed store, hash-verified

310}
311
312function buildUpstreamHeaders(
313 req: Pick<IncomingMessage, 'headers'>,
314 upstreamToken: string,
315 route: string,
316): Headers {
317 const headers = new Headers();
318 for (const name of FORWARDED_REQUEST_HEADERS) {
319 const value = req.headers[name];
320 if (typeof value === 'string' && value.trim()) headers.set(name, value);
321 }
322 if (route === '/rpc' && !headers.has('content-type')) {
323 headers.set('content-type', 'application/json');
324 }
325 for (const [name, value] of Object.entries(buildDaemonHttpAuthHeaders(upstreamToken))) {
326 headers.set(name, value);
327 }
328 return headers;
329}
330
331function resolveUpstreamBody(
332 req: IncomingMessage,

Callers 2

readUpstreamHealthFunction · 0.85
forwardProxyRequestFunction · 0.85

Calls 2

setMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…