Bug #44185

XML body always need a root node

Added by Bastian Waidelich about 8 years ago. Updated over 7 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
MVC
Start date:
2012-12-21
Due date:
% Done:

0%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

If the request contains xml and the Content-Type header is set to "*/xml" the client currently has to surround the XML with an additional root node (which is basically ignored):

curl -i -H "Accept: application/xml" -H "Content-Type: application/xml" -X POST -d "<anything><product><title>foo</title></product></anything>" http://localhost/products

Instead the root node should be omitted:

curl -i -H "Accept: application/xml" -H "Content-Type: application/xml" -X POST -d "<product><title>foo</title></product>" http://localhost/products

This could be achieved by replacing

$xmlElement = new \SimpleXMLElement(urldecode($body), LIBXML_NOERROR);


with
$xmlElement = new \SimpleXMLElement('<root>' . urldecode($body) . '</root>', LIBXML_NOERROR);

in Http\Request::decodeBodyArguments().

#1

Updated by Karsten Dambekalns over 7 years ago

  • Target version changed from 2.0 to 2.0.1

Also available in: Atom PDF