Introduce a custom header which servers can return to request cloudflared to not buffer the response.
This commit is contained in:
parent
c6901551e7
commit
83cd5b6cd1
|
@ -29,6 +29,8 @@ const (
|
|||
contentTypeHeader = "content-type"
|
||||
sseContentType = "text/event-stream"
|
||||
grpcContentType = "application/grpc"
|
||||
|
||||
FlushResponseHeader = "cf-cloudflared-flush-response"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -270,6 +272,10 @@ type ConnectedFuse interface {
|
|||
// Helper method to let the caller know what content-types should require a flush on every
|
||||
// write to a ResponseWriter.
|
||||
func shouldFlush(headers http.Header) bool {
|
||||
if headers.Get(FlushResponseHeader) == "yes" {
|
||||
return true
|
||||
}
|
||||
|
||||
if contentType := headers.Get(contentTypeHeader); contentType != "" {
|
||||
contentType = strings.ToLower(contentType)
|
||||
for _, c := range flushableContentTypes {
|
||||
|
|
Loading…
Reference in New Issue