You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit ec28ced
Browse filesBrowse the repository at this point in the historyBrowse files
fix: return 413 when the request body exceeds the configured limit (#2785)
`go_read_post` discarded read errors, so PHP saw a truncated
`php://input` when Caddy's `request_body max_size` (or any
`http.MaxBytesReader`) was exceeded. The request is now rejected with
413 if the error is a `*http.MaxBytesError` and response headers have
not been sent yet. This works in classic and worker mode.
Fixes#2781
You can find more information about this setting in the [Caddy documentation](https://caddyserver.com/docs/caddyfile/options#enable-full-duplex).
368
368
369
+
### Request body size limit
370
+
371
+
To limit the size of request bodies, use the [`request_body`](https://caddyserver.com/docs/caddyfile/directives/request_body) directive:
372
+
373
+
```caddyfile
374
+
request_body {
375
+
max_size 10MB
376
+
}
377
+
```
378
+
379
+
Requests with a larger body get a `413 Request Entity Too Large` response.
380
+
If PHP reads the body before the script starts (`POST` requests with a `Content-Type`, such as forms and file uploads), the script doesn't run.
381
+
If the script reads the body itself, through `php://input` or `request_parse_body()`, the read throws a `FrankenPHP\RequestBodyTooLargeException` once the limit is reached, so a truncated body is never mistaken for a complete one.
382
+
369
383
## Enable the debug mode
370
384
371
385
When using the Docker image, set the `CADDY_GLOBAL_OPTIONS` environment variable to `debug` to enable the debug mode:
* @param int $level The importance or severity of a log event. The higher the level, the more important or severe the event. For more details, see: https://pkg.go.dev/log/slog#Level
54
-
* array<string, any> $context Values of the array will be converted to the corresponding Go type (if supported by FrankenPHP) and added to the context of the structured logs using https://pkg.go.dev/log/slog#Attr
* @param int $level The importance or severity of a log event. The higher the level, the more important or severe the event. For more details, see: https://pkg.go.dev/log/slog#Level
58
+
* array<string, any> $context Values of the array will be converted to the corresponding Go type (if supported by FrankenPHP) and added to the context of the structured logs using https://pkg.go.dev/log/slog#Attr
0 commit comments