/** * Set a basic authentication header if basic authentication is set to be included in the request * headers * * @return string */ private function setupBasicAuthHeader() { $sHeaders = ''; $sCredential = $this->oConfig->getBasicAuthUser() . ":" . $this->oConfig->getBasicAuthPass(); $sHeaders .= 'Authorization: Basic ' . \base64_encode($sCredential) . self::HEADER_EOL; return $sHeaders; }
/** * Set curl default settings for connections. * * @param resource $rCurl * @param string $sUrl */ private function setDefaults($rCurl, $sUrl) { \curl_setopt($rCurl, \CURLOPT_URL, $sUrl); \curl_setopt($rCurl, \CURLOPT_ENCODING, 'gzip, deflate'); \curl_setopt($rCurl, \CURLOPT_USERAGENT, self::AGENT_NAME); //Transfer settings \curl_setopt($rCurl, \CURLOPT_FAILONERROR, true); \curl_setopt($rCurl, \CURLOPT_FRESH_CONNECT, true); \curl_setopt($rCurl, \CURLOPT_RETURNTRANSFER, true); \curl_setopt($rCurl, \CURLOPT_AUTOREFERER, true); \curl_setopt($rCurl, \CURLOPT_FORBID_REUSE, true); //Connection settings \curl_setopt($rCurl, \CURLOPT_CONNECTTIMEOUT, $this->oConfig->getConnectTimeout()); \curl_setopt($rCurl, \CURLOPT_TIMEOUT, $this->oConfig->getTimeout()); //Redirection settings may not be required \curl_setopt($rCurl, \CURLOPT_FOLLOWLOCATION, true); \curl_setopt($rCurl, \CURLOPT_MAXREDIRS, 1); \curl_setopt($rCurl, \CURLOPT_VERBOSE, $this->oConfig->isVerbose()); }