Feature #45293
Work Package #45088: Improved REST support
More flexible parsing of body arguments
Status: | Resolved | Start date: | 2013-02-08 | |
---|---|---|---|---|
Priority: | Should have | Due date: | 2013-04-13 | |
Assigned To: | Bastian Waidelich | % Done: | 100% |
|
Category: | Http | |||
Target version: | - | |||
PHP Version: | Complexity: | |||
Has patch: | No |
Description
Parsing of body arguments (e.g. xml, json) currently takes place in Http\Request and is hard-coded there.
Besides from being a bit buggy (e.g. you currently have to specify two root nodes like <root><product><title>changed title</title></product></root> where a common REST request would expected to be just <title>changed title</title>) the behavior can't be influenced easily because it happens so early in the request handling.
Related issues
Associated revisions
[!!!][FEATURE] Flexible parsing of request body arguments
Parsing of body arguments (e.g. xml, json) currently takes place in
``Http\Request`` and is hard-coded there.
This change extracts the decoding of body arguments from the request
class to a TypeConverter that is invoked by the ActionRequest only
if accessed.
The TypeConverter is referred to via a new marker interface
``MediaTypeConverterInterface``. In order to extend the media type
conversion, this interface has to be implemented by a custom
TypeConverter and set as default implementation in Objects.yaml::
TYPO3\Flow\Property\TypeConverter\MediaTypeConverterInterface:
className: 'Some\Custom\MediaTypeConverter'
This change also deprecates ``Http\Request::createActionRequest()``
in favor of ``$actionRequest = new ActionRequest($httpRequest);``
This is a breaking change in the rare case that
``Http\Request::getArguments()`` is expected to contain the parsed
request body already.
If you require to access those body arguments either use/create
an ActionRequest instance or parse the body arguments manually,
for example by using the PropertyMapper.
Change-Id: I1d192231810757f38aecfc3f7dc520b118ee3feb
Resolves: #45293
Releases: master
[BUGFIX] Properly merge request- and routing arguments
The "HTTP Components" feature (#52064) introduced a regression that
makes it very difficult to create RESTful services with Flow.
The problem is that the ``matchResults`` from the routing framework
override the arguments of the HTTP request instead of being
merged.
This change moves the merging of request- and routing arguments from
the ``ActionRequest`` to the ``DispatchComponent`` reducing the
complexity of argument merging and fixing the behavior of routing
values overriding the request arguments.
Note: This is a breaking change if you relied on the incorrect
behavior but it's not marked as such because there is no released
version that contains the regression.
Change-Id: Ida582e40c5306d5fa490c949d066e24f6dd63d09
Fixes: FLOW-43
Related: #45293
Related: #52064
Releases: master
History
#1 Updated by Bastian Waidelich over 2 years ago
Also see Marco Falkenbergs comment on #37604:
Some additional thoughts...
Processing of request content¶
In case of RESTful webservices the processing of the request's content should be more advanced and extensible. For now i.e. XML data is poorly treated by just converting over a SimpleXMLElement to an array. I know that this lack is mentioned by Robert in the comment, but there is no according issue tracker.
The funny thing is we have everything to make this work, because we have the property mapper with its type converters and their customizable configurations. Why don't allow IANA types AND class types as source types for a type converter? It's just pulling the responsibility for the property mapper one level up. Then you can implement the handling of XML data with your own XML type converter that i.e. accepts the source types 'application/xml', 'DOMNode', 'DOMElement', 'DOMDocument', 'DOMText'.
I tried it out and it works!
#2 Updated by Bastian Waidelich over 2 years ago
In addition: Currently only a fixed set of mediaTypes are supported, when specifying a Content-Type header like application/hal+json the body arguments are ignored!
#3 Updated by Bastian Waidelich over 2 years ago
- Parent task set to #45088
#4 Updated by Aske Ertmann over 2 years ago
- Parent task deleted (
#45088)
#5 Updated by Aske Ertmann over 2 years ago
- Parent task set to #45088
#6 Updated by Bastian Waidelich over 2 years ago
- Due date set to 2013-04-06
#7 Updated by Bastian Waidelich over 2 years ago
- Due date changed from 2013-04-06 to 2013-04-13
#8 Updated by Robert Lemke about 2 years ago
- Target version deleted (
2.1)
#9 Updated by Gerrit Code Review about 2 years ago
- Status changed from New to Under Review
Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21134
#10 Updated by Bastian Waidelich about 2 years ago
- % Done changed from 0 to 80
#11 Updated by Gerrit Code Review almost 2 years ago
Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21134
#12 Updated by Gerrit Code Review almost 2 years ago
Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21134
#13 Updated by Gerrit Code Review almost 2 years ago
Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21134
#14 Updated by Gerrit Code Review almost 2 years ago
Patch set 5 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21134
#15 Updated by Bastian Waidelich almost 2 years ago
- % Done changed from 80 to 100
#16 Updated by Gerrit Code Review almost 2 years ago
Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21134
#17 Updated by Gerrit Code Review almost 2 years ago
Patch set 7 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21134
#18 Updated by Gerrit Code Review almost 2 years ago
Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/21134
#19 Updated by Gerrit Code Review over 1 year ago
Patch set 9 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#20 Updated by Gerrit Code Review over 1 year ago
Patch set 10 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#21 Updated by Gerrit Code Review over 1 year ago
Patch set 11 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#22 Updated by Gerrit Code Review over 1 year ago
Patch set 12 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#23 Updated by Gerrit Code Review about 1 year ago
Patch set 13 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#24 Updated by Gerrit Code Review about 1 year ago
Patch set 14 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#25 Updated by Gerrit Code Review about 1 year ago
Patch set 15 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#26 Updated by Gerrit Code Review about 1 year ago
Patch set 16 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#27 Updated by Gerrit Code Review about 1 year ago
Patch set 17 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#28 Updated by Gerrit Code Review about 1 year ago
Patch set 18 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#29 Updated by Gerrit Code Review about 1 year ago
Patch set 19 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#30 Updated by Gerrit Code Review about 1 year ago
Patch set 20 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#31 Updated by Gerrit Code Review about 1 year ago
Patch set 21 for branch master of project Packages/TYPO3.Flow has been pushed to the review server.
It is available at https://review.typo3.org/21134
#32 Updated by Rens Admiraal 12 months ago
- Status changed from Under Review to Resolved
Applied in changeset 27853b9fdca4582f386b0299b0282172fcaf35d7.