Skip to content

Commit

Permalink
Issue fabiolb#129: Support for server-sent events (SSE)
Browse files Browse the repository at this point in the history
Original PR fabiolb#130 by @madeddie

This patch adds a proxy.flushinterval option which
enables periodic flushing of the repsonse buffer.

Since this is a global option and the implications on
non-streaming HTTP requests are unknown the current
implementation limits the use of the flush interval to
requests where the 'Accept' header is set to
'text/event-stream' which identifies SSE requests.

This is really a route specific option and should be
configured as such once this becomes possible.
  • Loading branch information
magiconair authored and madeddie committed Aug 4, 2016
1 parent 0bfcf7b commit 78f9e00
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions fabio.properties
Expand Up @@ -274,14 +274,17 @@
# proxy.dialtimeout = 30s


# proxy.flushinterval configures periodic flushing of the
# response buffer for SSE (server-sent events) connections.
# They are detected when the 'Accept' header is
# 'text/event-stream'.
# proxy.flushinterval configures periodic flushing of
# the response buffer. The default is not to flush
# the response buffer periodically.
#
# The current implementaiton exists to support SSE
# (server-sent events) and sets the value only when
# the 'Accept' header is 'text/event-stream'.
#
# The default is
#
# proxy.flushinterval = 1s
# proxy.flushinterval = 0s


# proxy.maxconn configures the maximum number of cached
Expand Down
4 changes: 2 additions & 2 deletions proxy/proxy.go
Expand Up @@ -49,9 +49,9 @@ func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// To use the filtered proxy use
// h = newWSProxy(t.URL)

// use the flush interval for SSE (server-sent events)
// must be > 0s to be effective
case r.Header.Get("Accept") == "text/event-stream":
// use the flush interval for SSE (server-sent events)
// must be > 0s to be effective
h = newHTTPProxy(t.URL, p.tr, p.cfg.FlushInterval)

default:
Expand Down

0 comments on commit 78f9e00

Please sign in to comment.