Пример #1
0
 /**
  * @param string $verb
  * @param string $url
  * @param string $blob
  * @param array $headers
  *   Array of headers (e.g. "Content-type" => "text/plain").
  * @return array
  *   array($headers, $blob, $code)
  */
 public function send($verb, $url, $blob, $headers = array())
 {
     $lowVerb = strtolower($verb);
     if ($lowVerb === 'get' && $this->cache) {
         $cachePath = 'get/' . md5($url);
         $cacheLine = $this->cache->get($cachePath);
         if ($cacheLine && $cacheLine['expires'] > CRM_Utils_Time::getTimeRaw()) {
             return $cacheLine['data'];
         }
     }
     $result = parent::send($verb, $url, $blob, $headers);
     if ($lowVerb === 'get' && $this->cache) {
         $expires = CRM_Utils_Http::parseExpiration($result[0]);
         if ($expires !== NULL) {
             $cachePath = 'get/' . md5($url);
             $cacheLine = array('url' => $url, 'expires' => $expires, 'data' => $result);
             $this->cache->set($cachePath, $cacheLine);
         }
     }
     return $result;
 }