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"
|
contentTypeHeader = "content-type"
|
||||||
sseContentType = "text/event-stream"
|
sseContentType = "text/event-stream"
|
||||||
grpcContentType = "application/grpc"
|
grpcContentType = "application/grpc"
|
||||||
|
|
||||||
|
FlushResponseHeader = "cf-cloudflared-flush-response"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -270,6 +272,10 @@ type ConnectedFuse interface {
|
||||||
// Helper method to let the caller know what content-types should require a flush on every
|
// Helper method to let the caller know what content-types should require a flush on every
|
||||||
// write to a ResponseWriter.
|
// write to a ResponseWriter.
|
||||||
func shouldFlush(headers http.Header) bool {
|
func shouldFlush(headers http.Header) bool {
|
||||||
|
if headers.Get(FlushResponseHeader) == "yes" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
if contentType := headers.Get(contentTypeHeader); contentType != "" {
|
if contentType := headers.Get(contentTypeHeader); contentType != "" {
|
||||||
contentType = strings.ToLower(contentType)
|
contentType = strings.ToLower(contentType)
|
||||||
for _, c := range flushableContentTypes {
|
for _, c := range flushableContentTypes {
|
||||||
|
|
Loading…
Reference in New Issue