protected function prepareCurl(curl $curl, $getCurlObject)
{
if ($this->credentials instanceof SimpleCredentials) {
$curl->setopt(CURLOPT_USERPWD, $this->credentials->getUserID() . ':' . $this->credentials->getPassword());
}
// otherwise leave this alone, the new curl instance has no USERPWD yet
$headers = array('Depth: ' . $this->depth, 'Content-Type: ' . $this->contentType, 'User-Agent: ' . self::USER_AGENT);
$headers = array_merge($headers, $this->additionalHeaders);
if ($this->lockToken) {
$headers[] = 'Lock-Token: <' . $this->lockToken . '>';
}
foreach ($this->curlOptions as $option => $optionValue) {
$curl->setopt($option, $optionValue);
}
$curl->setopt(CURLOPT_RETURNTRANSFER, true);
$curl->setopt(CURLOPT_CUSTOMREQUEST, $this->method);
$curl->setopt(CURLOPT_HTTPHEADER, $headers);
$curl->setopt(CURLOPT_POSTFIELDS, $this->body);
if ($getCurlObject) {
$curl->parseResponseHeaders();
}
return $curl;
}