-
Notifications
You must be signed in to change notification settings - Fork 32
Better handling when unable to parse body content #76
Comments
Would it be an option to segregate the parsing fromt the
A Parsers should implement an interface ( Like this you can get rid of all this trial and error parsing and when a client passes a It would also allow future support for the XML variant of json |
@weierophinney Please have a look on my solution and explanation in #78. Thanks! |
Hotfix #76 - Parsing string data
@weierophinney I started on something in a branch called content-type-listener-parsing. |
This repository has been closed and moved to laminas-api-tools/api-tools-content-negotiation; a new issue has been opened at laminas-api-tools/api-tools-content-negotiation#9. |
Currently,
ContentTypeListener
, on PATCH, PUT, or DELETE requests with body content, will attempt one of the following:parse_str()
This latter is a fallback for unknown content types. If it is unable to parse the string content using
parse_str()
, it then uses the raw content. However, it tries to push this into aParameterDataContainer
using itssetBodyParams()
method — which only accepts arrays. As a result, when such a condition occurs, a fatal error occurs due to type mismatch.There are two potential approaches to take when this occurs:
ApiProblemResponse
with a status of 400, indicating client error, or a 415 (unsupported media type).ParameterDataContainer
, and allow processing to continue.The first possibility is likely most correct, as it indicates that we received content we cannot process. The second possibility will likely eventually lead to an
ApiProblemResponse
, however, due to inability to validate the data in zf-content-validation, or inability to process it within application code; it also leaves the possibility of processing it manually via a listener or application code.I hereby solicit help to make this feature happen, as it will resolve a number of reported issues. I would be okay with either approach; argue the approach you take well when submitting a patch.
The text was updated successfully, but these errors were encountered: