diff --git a/docs/config.md b/docs/config.md index 8350581c7..31df71d52 100644 --- a/docs/config.md +++ b/docs/config.md @@ -129,6 +129,32 @@ php_server [] { } ``` +### Full Duplex (HTTP/1) + +When using HTTP/1.x, it may be desirable to enable full-duplex mode to allow writing a response before the entire body +has been read. (for example: WebSocket, Server-Sent Events, etc.) + +This is an opt-in configuration that needs to be added to the global options in the `Caddyfile`: + +```caddyfile +{ + servers { + enable_full_duplex + } +} +``` + +> ![CAUTION] +> +> Enabling this option may cause old HTTP/1.x clients that don't support full-duplex to deadlock. +This can also be configured using the `CADDY_GLOBAL_OPTIONS` environment config: + +```sh +CADDY_GLOBAL_OPTIONS="servers { enable_full_duplex }" +``` + +You can find more information about this setting in the [Caddy documentation](https://caddyserver.com/docs/caddyfile/options#enable-full-duplex). + ## Environment Variables The following environment variables can be used to inject Caddy directives in the `Caddyfile` without modifying it: diff --git a/frankenphp.go b/frankenphp.go index 6272d12a3..8df3ee434 100644 --- a/frankenphp.go +++ b/frankenphp.go @@ -720,13 +720,6 @@ func go_sapi_flush(rh C.uintptr_t) bool { return true } - if r.ProtoMajor == 1 { - if _, err := r.Body.Read(nil); err != nil { - // Don't flush until the whole body has been read to prevent https://github.com/golang/go/issues/15527 - return false - } - } - if err := http.NewResponseController(fc.responseWriter).Flush(); err != nil { fc.logger.Error("the current responseWriter is not a flusher", zap.Error(err)) }