Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable full duplex for http1 connections #692

Merged
merged 10 commits into from
May 31, 2024
Merged
26 changes: 26 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,32 @@ php_server [<matcher>] {
}
```

### 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
}
}
```

withinboredom marked this conversation as resolved.
Show resolved Hide resolved
> ![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:
Expand Down
7 changes: 0 additions & 7 deletions frankenphp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down