Symfony / Silex的子请求

时间:2016-12-05 18:02:26

标签: php symfony curl httprequest silex

我试图在Silex / Symfony中进行子请求,我这样做:

$subRequest = HttpFoundation\Request::create('/api/whatsnext', 'GET', array('additionalMessage' => $additionalMessage), $request->cookies->all(), array(), $request->server->all());

return $this->getApp()->handle($subRequest, HttpKernelInterface::SUB_REQUEST, false)

如果我通过Postman客户端调用最终执行此子请求的函数,则它完全有效。处理该子请求背后的功能并返回响应。

如果我通过curl请求执行相同的调用,我总是得到一个类似于此的HTML响应,而不是该函数的实际响应:

<html>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="refresh" content="1;url=/api/whatsnext/?additionalMessage=thankYou" />

    <title>Redirecting to /api/whatsnext/?additionalMessage=thankYou</title>
</head>
<body>
    Redirecting to <a href="/api/whatsnext/?additionalMessage=thankYou">/api/whatsnext/?additionalMessage=thankYou</a>.
</body>
</html>

有人知道如何在卷曲请求中得到邮递员得到的正确结果吗?

我的卷曲请求如下:

curl -i -H "Content-Type: application/json" -H "Authorization: c081ca0a756ced0df0fcc24546d7e24f" -X POST -d '{"id":4,"answers":[{"answerMessageKey":"savedData","value":"myPrename","matchingAttribute":"prename","matchingService":"UserService"}]}' http://the-url-to-the-function-that-has-the-subrequest-in-the-end.local

感谢您的帮助!

0 个答案:

没有答案