public function setHTTPAdapter($type = null) {
    if(!$type) {
      $type = extension_loaded("curl") ? self::$HTTP_CURL : self::$HTTP_NATIVE_SOCKETS;
    }

    // nothing to be done
    if($type === $this->httpAdapterType) {
      return true;
    }

    // remember what was already set (ie., might have called decode() already)
    $prevDecode = null;
    $prevTimeouts = null;
    if($this->httpAdapter) {
      $prevDecode = $this->httpAdapter->decodeResp;
      $prevTimeouts = $this->httpAdapter->getTimeouts();
    }

    // the glue
    switch($type) {
      case self::$HTTP_NATIVE_SOCKETS:
        $this->httpAdapter = new SagNativeHTTPAdapter($this->host, $this->port);
        break;

      case self::$HTTP_CURL:
        $this->httpAdapter = new SagCURLHTTPAdapter($this->host, $this->port);
        break;

      default:
        throw SagException("Invalid Sag HTTP adapter specified: $type");
    }

    // restore previous decode value, if any
    if(is_bool($prevDecode)) {
      $this->httpAdapter->decodeResp = $prevDecode;
    }

    // restore previous timeout vlaues, if any
    if(is_array($prevTimeouts)) {
      $this->httpAdapter->setTimeoutsFromArray($prevTimeouts);
    }

    $this->httpAdapterType = $type;

    return $this;
  }