/** * @param \TYPO3\Flow\Http\Response $response * @param \TYPO3\Flow\Http\Request $request * * @throws \Flowpack\ElasticSearch\Transfer\Exception * @throws \Flowpack\ElasticSearch\Transfer\Exception\ApiException */ public function __construct(\TYPO3\Flow\Http\Response $response, \TYPO3\Flow\Http\Request $request = null) { $this->originalResponse = $response; $treatedContent = json_decode($response->getContent(), true); if (strlen($response->getContent()) > 0) { if ($treatedContent === null) { throw new Exception('The request returned an invalid JSON string which was "' . $response->getContent() . '".', 1338976439, $response, $request); } if (array_key_exists('error', $treatedContent)) { throw new Exception\ApiException($treatedContent['error'], 1338977435, $response, $request); } } $this->treatedContent = $treatedContent; }
/** * @param string $url * @param string $method * @param Response $response * @return void */ public function logApiCall($url, $method, Response $response) { if ($this->settings['gitApi']['requestListener']['log'] === TRUE) { $directory = $this->getLogDirectory(); file_put_contents($directory . '/SurfCaptain_Request.log', $method . '_' . $url . "\n", FILE_APPEND); file_put_contents($directory . '/SurfCaptain_Request.log', $response->getContent() . "\n", FILE_APPEND); } }
/** * */ public function __construct($message, $code, \TYPO3\Flow\Http\Response $response, \TYPO3\Flow\Http\Request $request = NULL, \Exception $previous = NULL) { $this->response = $response; $this->request = $request; if ($request !== NULL) { $message = sprintf("[%s %s]: %s\n\nRequest data: %s", $request->getMethod(), $request->getUri(), $message . '; Response body: ' . $response->getContent(), $request->getContent()); } parent::__construct($message, $code, $previous); }
/** * Render this form. * * @return string rendered form * @api * @throws \TYPO3\Form\Exception\RenderingException */ public function render() { if ($this->isAfterLastPage()) { $this->invokeFinishers(); return $this->response->getContent(); } $this->formState->setLastDisplayedPageIndex($this->currentPage->getIndex()); if ($this->formDefinition->getRendererClassName() === NULL) { throw new \TYPO3\Form\Exception\RenderingException(sprintf('The form definition "%s" does not have a rendererClassName set.', $this->formDefinition->getIdentifier()), 1326095912); } $rendererClassName = $this->formDefinition->getRendererClassName(); $renderer = new $rendererClassName(); if (!$renderer instanceof \TYPO3\Form\Core\Renderer\RendererInterface) { throw new \TYPO3\Form\Exception\RenderingException(sprintf('The renderer "%s" des not implement RendererInterface', $rendererClassName), 1326096024); } $controllerContext = $this->getControllerContext(); $renderer->setControllerContext($controllerContext); $renderer->setFormRuntime($this); return $renderer->renderRenderable($this); }
/** * @test */ public function contentCanBeSetAppendedAndRetrieved() { $response = new Response(); $response->setContent('Two households, both alike in dignity, '); $response->appendContent('In fair Verona, where we lay our scene'); $this->assertEquals('Two households, both alike in dignity, In fair Verona, where we lay our scene', $response->getContent()); $response->setContent('For never was a story of more woe, Than this of Juliet and her Romeo.'); $this->assertEquals('For never was a story of more woe, Than this of Juliet and her Romeo.', $response->getContent()); $this->assertEquals('For never was a story of more woe, Than this of Juliet and her Romeo.', (string) $response); }
/** * Returns the DOM crawler which can be used to interact with the web page * structure, submit forms, click links or fetch specific parts of the * website's contents. * * The returned DOM crawler is bound to the response of the last executed * request. * * @return \Symfony\Component\DomCrawler\Crawler * @api */ public function getCrawler() { $crawler = new Crawler(null, $this->lastRequest->getBaseUri()); $crawler->addContent($this->lastResponse->getContent(), $this->lastResponse->getHeader('Content-Type')); return $crawler; }
public function equals($string) { $this->test->assertSame($string, $this->response->getContent(), 'The Response did not equal the string <' . $string . '>'); return $this; }
/** * @param string $path * @return string * @throws \Exception */ public function render($path = NULL) { if ($path === NULL) { $path = '404'; } /** @var RequestHandler $activeRequestHandler */ $activeRequestHandler = $this->bootstrap->getActiveRequestHandler(); $parentHttpRequest = $activeRequestHandler->getHttpRequest(); $requestPath = $parentHttpRequest->getUri()->getPath(); $language = explode('/', ltrim($requestPath, '/'))[0]; if ($language === 'neos') { throw new \Exception('NotFoundViewHelper can not be used for neos-routes.', 1435648210); } $language = $this->localeDetector->detectLocaleFromLocaleTag($language)->getLanguage(); if ($this->contentDimensionPresetSource->findPresetByUriSegment('language', $language) === NULL) { $language = ''; } if ($language !== '') { $language .= '/'; } $request = Request::create(new Uri(rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path)); $matchingRoute = $this->router->route($request); if (!$matchingRoute) { throw new \Exception(sprintf('Uri with path "%s" could not be found.', rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path), 1426446160); } $response = new Response(); $objectManager = $this->bootstrap->getObjectManager(); $baseComponentChain = $objectManager->get('TYPO3\\Flow\\Http\\Component\\ComponentChain'); $componentContext = new ComponentContext($request, $response); $baseComponentChain->handle($componentContext); return $response->getContent(); }