-
-
Notifications
You must be signed in to change notification settings - Fork 167
Closed
Labels
Milestone
Description
Hello there,
I have implemented a Mercure Hub with ReactPHP and I'm having troubles with request bodies.
I'm currently trying to achieve this:
POST /.well-known/mercure
Content-Type: application/x-www-form-urlencoded
topic=/foo&topic=/bar&data=foobarIndeed, the Mercure protocol specification states that a topic /foo can have alternate IRIs such as /bar. The payload to be sent is not in the PHP format topic[]=foo&topic[]=bar but topic=/foo&topic=/bar which means that PHP, by default, considers that topic is a string with the only value /bar, which is not what I want.
And so is the React\Http\Middleware\RequestBodyParserMiddleware which internally relies on PHP's parse_str function.
So, I'd like to implement my own logic to parse the body payload by myself, but:
- It looks like ReactPHP removes any trace of the original body at some point (
$request->getBody()returns an empty string), whenContent-Typeisapplication/x-www-form-urlencoded(could not reproduce with a random content type) - It looks like the only way to short-circuit the
RequestBodyParserMiddlewareto introduce my own is to set an empty value for enable_post_data_reading inphp.ini, but I cannot assume people who will use my project have this tricky tweak in their configuration.
Could we either:
- Not remove the original body of the request
- Introduce an interface for
RequestBodyParserMiddlewareso that we could optionally replace it inServer's constructor - Introduce an
array $configof options intoServer's constructor so that we could pass an option to prevent parsing request bodies and let our own middlewares take care of this?
Thank you,
Ben
Reactions are currently unavailable