Пример #1
0
 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;
 }
Пример #2
0
 /**
  * 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());
 }
Пример #3
0
 /**
  * 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);
 }
Пример #4
0
 public function testGetServer()
 {
     $request = new Request('http://www.example.com/', 'get', array(), array(), array(), array('foo' => 'bar'));
     $this->assertEquals(array('foo' => 'bar'), $request->getServer(), '->getServer() returns the server parameters of the request');
 }