miekg / caddy-prometheus

Prometheus metrics middleware for caddy
Apache License 2.0
65 stars 26 forks source link

Fallthrough to embedded responsewriter's httpFlusher interface #53

Open Rhionin opened 5 years ago

Rhionin commented 5 years ago

This plugin breaks server-sent events proxying through caddy, because it breaks the httpFlusher interface and makes responses hang with a buffer. This change implements httpFlusher on the timedResponseWriter as a fallthrough to the embedded responsewriter, or no-op if unavailable.

hairyhenderson commented 5 years ago

@Rhionin what's the error that you see without this fix?

lou-lan commented 5 years ago

@Rhionin log error example ?

panic: *metrics.timedResponseWriterHijacker is not a flusher
Rhionin commented 4 years ago

Hi, sorry for the long delay in replying. The error I see is that flushing the response buffer silently gets stuck at this misleading middleware, because it wraps the original response writer and makes the Flush interface become unavailable. I was encountering this when proxying server-sent events (SSE) through a caddy instance