Beispiel #1
0
 /**
  * @param \Blar\Curl\Curl $curl Curl.
  * @param \Blar\Http\HttpResponse $response Response.
  * @return $this
  */
 protected function configureCurl(Curl $curl, HttpResponse $response)
 {
     $curl->setMethod($this->getMethod());
     $curl->setUrl($this->getUrl());
     if ($this->getHeaders()) {
         $headers = $this->createHeadersArray($this->getHeaders());
         $curl->setOption(CURLOPT_HTTPHEADER, $headers);
     }
     if ($this->getBody()) {
         $curl->setBody($this->getBody());
     }
     $curl->setHeaderCallback(function ($header) use($response) {
         $response->setHeaderLine($header);
     });
     $curl->setWriteCallback(function ($part) use($response) {
         $response->addBodyPart($part);
     });
     return $this;
 }