コード例 #1
0
 public function setUp()
 {
     $this->originalServerResponse = new OriginalServerResponse();
     $this->originalServerResponse->setCode(302);
     $this->originalServerResponse->setHeadersRaw("HTTP/1.1 302 Found\n            Server: nginx\n            Date: Fri, 06 Jun 2014 18:18:27 GMT\n            Content-Type: text/html\n            Transfer-Encoding: chunked\n            Connection: keep-alive\n            Keep-Alive: timeout=120\n            Cache-Control: max-age=0, proxy-revalidate\n            Expires: Fri, 06 Jun 2014 18:23:27 GMT\n            Location: https://money.yandex.ru/select-wallet.xml?requestid=313038323634363833375f39393063623232643562343937326333663832666537333037363935336138643961396235333439");
     $this->originalServerResponse->setBodyRaw('{"response":{"code":115,"status":"ok","message":"Categories ready","categories":[{"_id":1,"category":"Расходники"},{"_id":2,"category":"Детали подвески"},{"_id":3,"category":"Тормозные системы"}]}}');
     $this->originalServerResponse->setErrorCode(1);
     $this->originalServerResponse->setErrorMessage("test_error");
 }
コード例 #2
0
 /**
  * @param string $uri
  * @param string $params
  * @return OriginalServerResponse
  */
 private function makePostCurlRequest($uri, $params)
 {
     $headers = $this->prepareRequestHeaders();
     $curl = curl_init($uri);
     curl_setopt($curl, CURLOPT_HEADER, true);
     curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
     if ($this->isSSLVerificationRequired()) {
         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
         curl_setopt($curl, CURLOPT_CAINFO, __DIR__ . self::CERTIFICATE_PATH);
     }
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 30);
     curl_setopt($curl, CURLOPT_TIMEOUT, 80);
     curl_setopt($curl, CURLOPT_POST, true);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
     $this->writeMessageToLogFile($this->prepareLogMessage($uri, $params));
     $responseRaw = curl_exec($curl);
     $errorCode = curl_errno($curl);
     $errorMessage = curl_error($curl);
     $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     $responseHeaderSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
     $responseHeadersRaw = trim(substr($responseRaw, 0, $responseHeaderSize));
     $responseBodyRaw = trim(substr($responseRaw, $responseHeaderSize));
     curl_close($curl);
     $this->writeMessageToLogFile($this->prepareLogMessageExtended($uri, $params, $responseCode, $errorCode, $errorMessage));
     $this->originalServerResponse = new OriginalServerResponse();
     $this->originalServerResponse->setCode($responseCode);
     $this->originalServerResponse->setHeadersRaw($responseHeadersRaw);
     $this->originalServerResponse->setBodyRaw($responseBodyRaw);
     $this->originalServerResponse->setErrorCode($errorCode);
     $this->originalServerResponse->setErrorMessage($errorMessage);
 }