/**
  * Sends a query to the service. By default all GET requests
  * are treated as queries which allows caching of responses.
  * @param EActiveResourceRequest $request The request object
  * @return EActiveResourceResponse The response object
  */
 public function query(EActiveResourceRequest $request)
 {
     //set connection component specific options
     $request->setCurlHandle($this->_ch);
     $request->setContentType($this->contentType);
     $request->setAcceptType($this->acceptType);
     //AUTH STUFF
     if (isset($this->auth)) {
         $request->setHttpLogin($this->auth['username'], $this->auth['password'], $this->auth['type']);
     }
     //API KEY STUFF
     if (isset($this->apiKey)) {
         $request->setApiKey($this->apiKey['value'], $this->apiKey['name']);
     }
     //SSL STUFF
     if (isset($this->ssl)) {
         $request->setSSL($this->ssl['verifyPeer'], $this->ssl['verifyHost'], $this->ssl['pathToCert']);
     }
     ///LOOK FOR CACHED RESPONSES FIRST
     if ($this->queryCachingCount > 0 && $this->queryCachingDuration > 0 && $this->queryCacheID !== false && ($cache = Yii::app()->getComponent($this->queryCacheID)) !== null) {
         $this->queryCachingCount--;
         $cacheKey = 'yii:eactiveresourcerequest:' . $request->getUri() . ':' . $request->getMethod() . ':' . $this->recursiveImplode('-', $request->getHeader());
         $cacheKey .= ':' . $this->recursiveImplode('#', $request->getData());
         if (($result = $cache->get($cacheKey)) !== false) {
             Yii::trace('Response found in cache', 'ext.EActiveResource.EActiveResourceConnection');
             return $result;
         }
     }
     $response = $request->run();
     //CACHE RESULT IF CACHE IS SET
     if (isset($cache, $cacheKey)) {
         $cache->set($cacheKey, $response, $this->queryCachingDuration, $this->queryCachingDependency);
     }
     if ($response->hasErrors()) {
         $response->throwError();
     }
     return $response;
 }