public function setOption($name, $value)
    {
        if ($name === ConnectionOptions::OPTION_ENDPOINT ||
            $name === ConnectionOptions::OPTION_HOST ||
            $name === ConnectionOptions::OPTION_PORT ||
            $name === ConnectionOptions::OPTION_VERIFY_CERT ||
            $name === ConnectionOptions::OPTION_CIPHERS ||
            $name === ConnectionOptions::OPTION_ALLOW_SELF_SIGNED
        ) {
            throw new ClientException('Must not set option ' . $value . ' after connection is created.');
        }

        $this->_options[$name] = $value;

        // special handling for several options
        if ($name === ConnectionOptions::OPTION_TIMEOUT) {
            // set the timeout option: patch the stream of an existing connection
            if (is_resource($this->_handle)) {
                stream_set_timeout($this->_handle, $value);
            }
        } else if ($name === ConnectionOptions::OPTION_CONNECTION) {
            // set keep-alive flag
            $this->_useKeepAlive = (strtolower($value) === 'keep-alive');
        } else if ($name === ConnectionOptions::OPTION_DATABASE) {
            // set database
            $this->setDatabase($value);
        }

        $this->updateHttpHeader();
    }