/** * execute curl * * @return Rakit\Curl\Response */ protected function execute() { if (TRUE === $this->closed) { throw new \Exception("Cannot execute curl session twice, create a new one!"); } if (!empty($this->cookies)) { $this->option(CURLOPT_COOKIE, http_build_query($this->cookies, '', '; ')); } $this->option(CURLOPT_HTTPHEADER, $this->headers); curl_setopt_array($this->curl, $this->options); $response = curl_exec($this->curl); $info = curl_getinfo($this->curl); $this->errno = $error = curl_errno($this->curl); $this->error_message = curl_error($this->curl); $this->response = new Response($info, $response, $this->errno, $this->error_message); $this->close(); if ($this->limit_redirect_count > 0) { $count_redirect = 0; while ($this->response->isRedirect()) { $this->redirect(); $count_redirect++; if ($count_redirect >= $this->limit_redirect_count) { break; } } } return $this->response; }
/** * Checks whether actual value is true * * @param Response $response * @return boolean */ public function matches($response) { if (!$response->isRedirect()) { $this->_actual = 'no url'; return false; } $headers = $response->sendHeaders(); $this->_actual = str_replace('Location: ', '', $headers['location']); return $this->_actual === $this->_expected; }
private static function startDispatch() { $buffering = !IN_CLI && self::$outputBuffer; if ($buffering) { ob_start(); } try { self::dispatch(); $controllerPath = self::$request->getControllerPath(); $actionFile = self::$request->getActionFile(); } catch (Exception $e) { if (IN_CLI) { throw $e; return; } $controllerPath = 'error'; self::$request->setUserParam('exception', $e); $controller = new ErrorController(); if ($e instanceof PageNotFoundException) { $actionFile = 'page-not-found'; self::$response->setHttpResponseCode(404); $controller->pageNotFoundAction(); } else { $actionFile = 'internal-error'; self::$response->setHttpResponseCode(500); $controller->internalErrorAction(); } } if (self::$shouldRender && !self::$response->isRedirect()) { self::$view->render($controllerPath, $actionFile); } if ($buffering && !self::$response->isRedirect()) { self::$response->setBody(ob_get_clean()); } self::$response->sendResponse(); }
public function testConstruct() { $data = array('sid' => '12345', 'total' => '10.00'); $mock = $this->getMockBuilder('\\Omnipay\\TwoCheckout\\Message\\Request')->disableOriginalConstructor()->getMock(); $mock->expects($this->once())->method('getAction')->will($this->returnValue('foo')); $response = new Response($mock, $data); $this->assertFalse($response->isSuccessful()); $this->assertTrue($response->isRedirect()); $this->assertNull($response->getTransactionReference()); $this->assertNull($response->getMessage()); $this->assertSame('foo', $response->getRedirectUrl()); $this->assertSame('POST', $response->getRedirectMethod()); $this->assertSame('POST', $response->getRedirectMethod()); $this->assertSame($data, $response->getRedirectData()); }
/** * Checks whether actual value is true * * @param Response $response * @return boolean */ public function matches($response) { return $response->isRedirect(); }