MCPcopy Create free account
hub / github.com/OpenHands/OpenHands / proxyHttp

Function proxyHttp

scripts/mars-web-bridge.mjs:509–528  ·  view source on GitHub ↗
(req, res, { sessionId, path })

Source from the content-addressed store, hash-verified

507 }
508
509 function proxyHttp(req, res, { sessionId, path }) {
510 const target = upstreamFor(sessionId);
511 if (!target) {
512 writeJson(res, 409, {
513 error: { message: `session ${sessionId} is not connected` },
514 });
515 return;
516 }
517 const proxyBase = sessionProxyBase(req, sessionId);
518 toUpstreamRequest(req, path);
519 proxy.proxyHttp(req, res, target, {
520 // Responses are read as UTF-8 for the URL rewrite; a compressed body
521 // would have to be inflated first.
522 headers: { "accept-encoding": "identity" },
523 onResponse: rewriteJsonResponse(
524 (body) => rewriteAgentServerUrls(body, proxyBase),
525 { limit: JSON_REWRITE_LIMIT_BYTES },
526 ),
527 });
528 }
529
530 function proxyWebSocket(req, socket, head, { sessionId, path }) {
531 const target = upstreamFor(sessionId);

Callers 1

handleHttpFunction · 0.70

Calls 6

rewriteJsonResponseFunction · 0.90
upstreamForFunction · 0.85
writeJsonFunction · 0.85
sessionProxyBaseFunction · 0.85
toUpstreamRequestFunction · 0.85
rewriteAgentServerUrlsFunction · 0.85

Tested by

no test coverage detected