(req, res, { sessionId, path })
| 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); |
no test coverage detected