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

Function proxyHttp

scripts/proxy-utils.mjs:239–266  ·  view source on GitHub ↗
(req, res, target)

Source from the content-addressed store, hash-verified

237 });
238
239 function proxyHttp(req, res, target) {
240 metrics.activeHttpRequests += 1;
241 metrics.totalHttpRequests += 1;
242 const finish = once(() => {
243 metrics.activeHttpRequests = Math.max(0, metrics.activeHttpRequests - 1);
244 });
245 res.on("close", finish);
246 res.on("finish", finish);
247 res.on("error", finish);
248
249 const handleProxyError = (err) => {
250 metrics.totalErrors += 1;
251 if (!isBenignSocketError(err)) {
252 console.error(
253 `[${label}] Proxy error for ${req.url} -> ${target}:`,
254 err,
255 );
256 }
257 writeProxyError(res, err instanceof Error ? err.message : String(err));
258 finish();
259 };
260
261 try {
262 proxy.web(req, res, { target }).catch(handleProxyError);
263 } catch (err) {
264 handleProxyError(err);
265 }
266 }
267
268 function proxyWebSocket(req, socket, head, target) {
269 metrics.activeWebSockets += 1;

Callers

nothing calls this directly

Calls 2

onceFunction · 0.85
handleProxyErrorFunction · 0.85

Tested by

no test coverage detected