protected function createClient(Request $request) { $client = $this->createZendClient(); $client->setUri($request->getUri()); $client->setConfig(array_merge(array('maxredirects' => 0, 'timeout' => 30, 'useragent' => $this->server['HTTP_USER_AGENT'], 'adapter' => 'Zend_Http_Client_Adapter_Socket'), $this->zendConfig)); $client->setMethod(strtoupper($request->getMethod())); if ('post' == $request->getMethod()) { $client->setParameterPost($request->getParameters()); } else { $client->setParameterGet($request->getParameters()); } foreach ($this->getCookieJar()->getValues($request->getUri()) as $name => $value) { $client->setCookie($name, $value); } return $client; }
/** * Converts the BrowserKit request to a HttpKernel request. * * @param Symfony\Components\BrowserKit\Request $request A Request instance * * @return Symfony\Components\HttpKernel\Request A Request instance */ protected function filterRequest(DomRequest $request) { $uri = $request->getUri(); if (preg_match('#^https?\\://([^/]+)/(.*)$#', $uri, $matches)) { $uri = '/' . $matches[2]; } return Request::create($uri, $request->getMethod(), $request->getParameters(), $request->getFiles(), $request->getCookies(), $request->getServer()); }
/** * Makes a request from a Request object directly. * * @param Symfony\Components\BrowserKit\Request $request A Request instance * @param Boolean $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()) * * @return Symfony\Components\DomCrawler\Crawler */ protected function requestFromRequest(Request $request, $changeHistory = true) { return $this->request($request->getMethod(), $request->getUri(), $request->getParameters(), array(), $request->getFiles(), $request->getServer(), $changeHistory); }
public function testGetUri() { $request = new Request('http://www.example.com/', 'get'); $this->assertEquals('http://www.example.com/', $request->getUri(), '->getUri() returns the URI of the request'); }