예제 #1
0
파일: FileLogger.php 프로젝트: noikiy/Curl
 /**
  * @param \Kdyby\Curl\Response $response
  * @param string $id
  */
 public function response(Curl\Response $response, $id)
 {
     $content = array();
     foreach ($response->getHeaders() as $name => $value) {
         $content[] = "{$name}: {$value}";
     }
     $content = '< ' . implode("\n< ", $content);
     $this->write($content . "\n\n", $id);
     $body = $response->getResponse();
     foreach ($this->formatters as $formatter) {
         if ($formatted = $formatter($body, $response)) {
             $body = $formatted;
         }
     }
     $this->write($body, $id);
 }
예제 #2
0
 /**
  * @param string $policyNo
  * @param Response $response
  * @return bool|string
  */
 public function savePdfFile($policyNo, Response $response)
 {
     if ($response->getHeaders()['Content-Type'] !== 'application/pdf') {
         return FALSE;
     }
     $body = $response->getResponse();
     $filename = $this->tempDir . '/' . $policyNo . '-' . Strings::substring(md5($body), 0, 5) . '.pdf';
     $this->toDelete[] = $filename;
     FileSystem::write($filename, $body);
     return $filename;
 }