protected function curlGetOptions($url, $options = array())
    {
        $this->debug->groupCollapsed(__METHOD__);
        $urlParts = Html::parseUrl($url);
        $optionsDefault = $this->curlOptionsDefault($url);
        $options = $this->curlOptionsNormalize($options);
        // $this->debug->log('optionsDefault', $optionsDefault);
        $options = ArrayUtil::mergeDeep($optionsDefault, $options);
        $options['CURLOPT_URL'] = \str_replace(' ', '%20', $options['CURLOPT_URL']);
        $options['CURLOPT_FOLLOWLOCATION']  = false;    // we will follow manually
        if ($options['verbose']) {
            $options['CURLOPT_VERBOSE'] = true;
            /*
            $options['tempfile'] = tempnam(\sys_get_temp_dir(), 'curl_');
            if (\is_writable($options['tempfile'])) {
                $fh = \fopen($options['tempfile'], 'w+');
                $options['CURLOPT_STDERR'] = $fh;
            }
            */
            $options['CURLINFO_HEADER_OUT'] = false;    // https://bugs.php.net/bug.php?id=65348
            $options['CURLOPT_STDERR'] = \fopen('php://temp', 'rw');
        }
        if (!empty($options['CURLOPT_PROXY']) && \in_array($urlParts['host'], array('127.0.0.1','localhost'))) {
            $this->debug->log('not using proxy for localhost');
            $options['CURLOPT_PROXY'] = false;  // formerly set to null... which no longer works
        }
        if (empty($options['CURLOPT_PROXY']) && \getenv('http_proxy')) {
            $this->debug->log('http_proxy env variable is set.... setting NO_PROXY env variable');
            \putenv('NO_PROXY='.$urlParts['host']);
        }
        $this->debug->groupEnd();
        return $options;
    }