protected function send(array $customHeader = [], $fullResponse = false)
{
if (!empty($customHeader)) {
$header = $customHeader;
} else {
$header = [];
if (count($this->header) > 0) {
$header = $this->header->build();
}
}
$header[] = 'Expect:';
$header = array_unique($header, SORT_STRING);
$this->responseHeader = '';
$this->setOption(CURLOPT_HEADERFUNCTION, [$this, 'headerFunction']);
$this->setOption(CURLOPT_HTTPHEADER, $header);
$content = curl_exec($this->handle);
$this->setOption(CURLOPT_HEADERFUNCTION, null);
if ($errno = curl_errno($this->handle)) {
throw new HttpException(curl_error($this->handle), $errno);
}
$response = new Response();
$response->header->parse($this->responseHeader);
if ($fullResponse) {
$response->body = $content;
} else {
$response->body = substr($content, strlen($this->responseHeader));
}
return $response;
}