File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,13 @@ bin/cake upgrade rector --rules cakephp55 <path/to/app/src>
3333 this method must add the optional parameter to their signature and pass it
3434 through when calling ` parent::addDefaultTypes() ` .
3535
36+ ### Http
37+
38+ - HTTP method overrides from ` _method ` or ` X-Http-Method-Override ` are normalized
39+ to uppercase. Invalid syntax and non-string values now raise
40+ ` BadRequestException ` (HTTP 400). See
41+ [ HTTP Method Overrides] ( ../controllers/request-response#http-method-overrides ) .
42+
3643## Deprecations
3744
3845Coming soon
Original file line number Diff line number Diff line change @@ -514,6 +514,27 @@ Returns the HTTP method the request was made with:
514514echo $request->getMethod();
515515```
516516
517+ ### HTTP Method Overrides
518+
519+ ` ServerRequestFactory::fromGlobals() ` supports a ` _method ` request-body field
520+ or an ` X-Http-Method-Override ` header to override the request method. The
521+ header takes precedence over the body field. ` _method ` is removed from the
522+ parsed body. Use
523+ ` $request->getEnv('ORIGINAL_REQUEST_METHOD') ` to read the original method.
524+
525+ Override values are converted to uppercase and must contain letters A-Z,
526+ optionally separated by single hyphens or underscores. For example, ` patch ` ,
527+ ` VERSION-CONTROL ` and ` CUSTOM_METHOD ` are accepted; digits, whitespace, repeated
528+ separators and array values are rejected.
529+
530+ Invalid values throw ` BadRequestException ` with the message
531+ ` Invalid HTTP method override. ` and result in HTTP 400. This happens while
532+ building the request, before the middleware queue runs.
533+
534+ ::: info Added in version 5.5.0
535+ Validation and normalization of HTTP method overrides were added.
536+ :::
537+
517538### Restricting HTTP Methods per Action
518539
519540` method ` Cake\\ Http\\ ServerRequest::** allowMethod** (array|string $methods): bool
You can’t perform that action at this time.
0 commit comments