Example #1
0
 /**
  * Helper method to execute deferred HTTP requests.
  *
  * @param $request W3TCG_Google_Http_Request|Google_Http_Batch
  * @throws W3TCG_Google_Exception
  * @return object of the type of the expected class or array.
  */
 public function execute($request)
 {
     if ($request instanceof W3TCG_Google_Http_Request) {
         $request->setUserAgent($this->getApplicationName() . " " . self::USER_AGENT_SUFFIX . $this->getLibraryVersion());
         if (!$this->getClassConfig("W3TCG_Google_Http_Request", "disable_gzip")) {
             $request->enableGzip();
         }
         $request->maybeMoveParametersToBody();
         return W3TCG_Google_Http_REST::execute($this, $request);
     } else {
         if ($request instanceof W3TCG_Google_Http_Batch) {
             return $request->execute();
         } else {
             throw new W3TCG_Google_Exception("Do not know how to execute this type of object.");
         }
     }
 }