🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@MatTheCat
Copy link
Contributor

@MatTheCat MatTheCat commented Oct 5, 2025

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? no
Issues Fix #59331
License MIT

Seeing that #59358 is stalled I’m opening this PR in the hope of seeing this feature in 7.4/8.0 (if it’s okay with you @rottifant).

When using PHP ≥ 8.4, this PR will try to parse a PUT, DELETE, PATCH or QUERY request body using request_parse_body to populate Request::$request and $files.

No options are passed so that php.ini settings apply.

RequestParseBodyException (thrown when the request body is invalid, according to the Content-Type) is ignored for now.

An important point is that when dealing with multipart/form-data requests, request_parse_body will only work if the input stream hasn’t been consumed (by reading php://input or by another call to request_parse_body). This PR won’t override Request::$request and $files so that the input stream can be read before createFromGlobals is called, but I don’t know how to preserve BC if it is read after (in which case it will be empty).

@nicolas-grekas nicolas-grekas changed the title [HttpFoundation] Make Request::createFromGlobals() use request_parse_body when possible [HttpFoundation] Make Request::createFromGlobals() parse the body of PUT, DELETE, PATCH and QUERY requests Oct 6, 2025
@fabpot
Copy link
Member

fabpot commented Oct 9, 2025

Thank you @MatTheCat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for multipart/form-data in non-POST requests using request_parse_body() (PHP 8.4)

4 participants