private function setOption($key, $value) {
    switch ($key) {
      // Cases that we support.
      case CURLOPT_FOLLOWLOCATION:
        $this->request->setFollowRedirects($value);
        break;
      case CURLOPT_HTTPGET:
        $this->request->setMethod(RequestMethod::GET);
        break;
      case CURLOPT_NOBODY:
        $this->request->setMethod(RequestMethod::HEAD);
        break;
      case CURLOPT_POST:
        $this->request->setMethod(RequestMethod::POST);
        break;
      case CURLOPT_PUT:
        $this->request->setMethod(RequestMethod::PUT);
        break;
      case CURLOPT_SSL_VERIFYPEER:
        $this->request->setMustValidateServerCertificate($value);
        break;
      case CURLOPT_TIMEOUT:
        $this->request->setDeadline($value);
        break;
      case CURLOPT_TIMEOUT_MS:
        $this->request->setDeadline($value * 1000);
        break;
      case CURLOPT_CUSTOMREQUEST:
        if (!in_array($value, array_keys(static::$custom_request_map))) {
          throw new CurlLiteOptionNotSupportedException(
              'Custom request ' . $value . ' not supported by this curl ' .
              'implementation.');
        }
        $this->request->setMethod(static::$custom_request_map[$value]);
        break;
      case CURLOPT_RANGE:
        $this->headers['Range'] = $value;
        break;
      case CURLOPT_REFERER:
        $this->headers['Referer'] = $value;
        $break;
      case CURLOPT_URL:
        $this->setRequestUrl($value);
        break;
      case CURLOPT_USERAGENT:
        $this->headers['User-Agent'] = $value;
        break;
      case CURLOPT_COOKIE:
        $this->headers['Cookie'] = $value;
        break;
      case CURLOPT_HTTPHEADER:
        $this->headers = ArrayUtil::arrayMergeIgnoreCase(
            $this->headers, $this->parseHttpHeaders($value));
        break;
      // Cases that we don't support, that could cause a semantic change in the
      // application by not supporting.
      case CURLOPT_COOKIESESSION:
      case CURLOPT_CERTINFO:
      case CURLOPT_CONNECT_ONLY:
      case CURLOPT_FTP_USE_EPRT:
      case CURLOPT_FTP_USE_EPSV:
      case CURLOPT_FTP_CREATE_MISSING_DIRS:
      case CURLOPT_FTPAPPEND:
      case CURLOPT_FTPLISTONLY:
      case CURLOPT_HTTPPROXYTUNNEL:
      case CURLOPT_NETRC:
      case CURLOPT_NOSIGNAL:
      case CURLOPT_SAFE_UPLOAD:
      case CURLOPT_TRANSFERTEXT:
      case CURLOPT_FTPSSLAUTH:
      case CURLOPT_TIMEVALUE:
      case CURLOPT_CAINFO:
      case CURLOPT_COOKIEJAR:
      case CURLOPT_FTPPORT:
      case CURLOPT_KEYPASSWD:
      case CURLOPT_KRB4LEVEL:
      case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5:
      case CURLOPT_SSH_PUBLIC_KEYFILE:
      case CURLOPT_SSH_PRIVATE_KEYFILE:
      case CURLOPT_SSLCERT:
      case CURLOPT_SSLCERTPASSWD:
      case CURLOPT_SSLCERTTYPE:
      case CURLOPT_SSLENGINE:
      case CURLOPT_SSLENGINE_DEFAULT:
      case CURLOPT_SSLKEY:
      case CURLOPT_SSLKEYPASSWD:
      case CURLOPT_SSLKEYTYPE:
      case CURLOPT_POSTQUOTE:
      case CURLOPT_QUOTE:
      case CURLOPT_PROGRESSFUNCTION:
      case CURLOPT_SHARE:
        throw new CurlLiteOptionNotSupportedException(
          'Option ' . $key . ' is not supported by this curl implementation.');

      // Everything else is a no-op, or will be configured at request time.
      default:
    }
    $this->options[$key] = $value;
    return true;
  }