Skip to the content.

RFC 0005: Streaming and WebSocket Support in Ingress

Summary

Rewrite the ingress proxy to support bidirectional streaming and WebSocket upgrade, replacing the current request-buffer-respond pattern.

Problem

_proxy() in proxy/ingress.py (lines 100-111) does await request.read() then await resp.read() and returns a single web.Response. This means:

Files to Modify

Implementation

  1. Detect Connection: Upgrade / Upgrade: websocket headers at the top of the handler
  2. For WebSocket requests: establish a bidirectional pipe between client and upstream using aiohttp.web.WebSocketResponse
  3. For normal requests: use aiohttp.web.StreamResponse instead of buffering the full response
  4. Stream the request body to upstream chunk-by-chunk (don’t buffer)
  5. Stream the response body back chunk-by-chunk
  6. Handle backpressure properly — pause reading if the write buffer is full
  7. Handle Transfer-Encoding: chunked responses
  8. Handle Content-Encoding: gzip/deflate — pass through without decompressing
  9. Support Accept-Encoding: text/event-stream for SSE passthrough

Testing & Validation Requirements

Report Requirements

Priority

This is the single biggest limitation of the current platform. Unblocks tunnel performance (#8) and real-time applications.