Commit 257cb98b authored by Mateu Aguiló Bosch's avatar Mateu Aguiló Bosch

Support write requests

parent e11e3858
......@@ -293,6 +293,9 @@ class RequestTree {
(array) $request->server->getIterator(),
$content
);
foreach ($request->headers as $key => $val) {
$new_request->headers->set($key, $val);
}
$new_request->headers->set('Content-ID', sprintf('<%s>', $id));
$new_request->attributes->set(static::SUBREQUEST_PARENT_ID, $parent_id);
$new_request->attributes->set(static::SUBREQUEST_ID, $id);
......
......@@ -3,6 +3,7 @@
namespace Drupal\subrequests\Normalizer;
use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\NestedArray;
use Drupal\subrequests\Blueprint\Parser;
use Drupal\subrequests\Blueprint\RequestTree;
......@@ -32,11 +33,11 @@ class JsonSubrequestDenormalizer implements DenormalizerInterface {
parse_str($data['query'], $query);
$data['query'] = $query;
}
$data = NestedArray::mergeDeep($data, [
'body' => [],
$data = NestedArray::mergeDeep([
'body' => '',
'query' => [],
'headers' => [],
], parse_url($data['path']));
], $data, parse_url($data['path']));
/** @var \Symfony\Component\HttpFoundation\Request $master_request */
$master_request = $context['master_request'];
......@@ -44,7 +45,7 @@ class JsonSubrequestDenormalizer implements DenormalizerInterface {
$request = Request::create(
$data['path'],
static::getMethodFromAction($data['action']),
empty($data['body']) ? $data['query'] : $data['body'],
empty($data['body']) ? $data['query'] : Json::decode($data['body']),
$master_request->cookies ? (array) $master_request->cookies->getIterator() : [],
$master_request->files ? (array) $master_request->files->getIterator() : [],
$master_request->server ? (array) $master_request->server->getIterator() : [],
......
......@@ -6,5 +6,6 @@ subrequests.front-controller:
methods: [POST]
options:
no_cache: TRUE
_auth: ['basic_auth', 'cookie', 'oauth2']
requirements:
_permission: 'issue subrequests'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment