httpingress: responseWriter should forward optional HTTP interfaces (Flusher/Hijacker/Pusher)
The responseWriter wrapper in servers/httpingress/httpingress.go currently doesn't forward optional HTTP interfaces, which can break or degrade WebSockets, Server-Sent Events (SSE), HTTP/2 push, and other streaming features.
Problem
The responseWriter struct wraps http.ResponseWriter but doesn't implement optional interfaces like:
http.Flusher- needed for SSE and streaming responseshttp.Hijacker- needed for WebSocket upgradeshttp.Pusher- needed for HTTP/2 server push
Without these, attempts to use these features will fail or degrade performance.
Solution
Add passthrough methods that check if the underlying ResponseWriter supports these interfaces and delegate to them:
// Optional interfaces passthroughs
func (rw *responseWriter) Flush() {
if f, ok := rw.ResponseWriter.(http.Flusher); ok {
f.Flush()
}
}
func (rw *responseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if h, ok := rw.ResponseWriter.(http.Hijacker); ok {
return h.Hijack()
}
return nil, nil, fmt.Errorf("http.Hijacker not supported by underlying ResponseWriter")
}
func (rw *responseWriter) Push(target string, opts *http.PushOptions) error {
if p, ok := rw.ResponseWriter.(http.Pusher); ok {
return p.Push(target, opts)
}
return fmt.Errorf("http.Pusher not supported by underlying ResponseWriter")
}
Context
This was identified during code review of the request timeout implementation (PR #202). The existing Unwrap() method is good for middleware compatibility, but these explicit interface implementations are needed for proper HTTP feature support.
References
- Original PR: https://github.com/mirendev/runtime/pull/202
- Location:
servers/httpingress/httpingress.golines 450-471