private function init(string $url): void
    {
        $this->resource = curl_init($url);

        curl_setopt($this->resource, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->resource, CURLOPT_CONNECTTIMEOUT, $this->loader->getTimeout());
        curl_setopt($this->resource, CURLOPT_USERAGENT, $this->loader->getUserAgent());
        curl_setopt($this->resource, CURLOPT_HEADER, true);
        curl_setopt($this->resource, CURLINFO_HEADER_OUT, true);

        // check and set proxy settings
        $proxy_host = $this->loader->getOption('ProxyHost');

        if (null !== $proxy_host) {
            // check for supported protocol
            $proxy_protocol = $this->loader->getOption('ProxyProtocol');

            if (null !== $proxy_protocol) {
                $allowedProtocolls = [StreamCreator::PROXY_PROTOCOL_HTTP, StreamCreator::PROXY_PROTOCOL_HTTPS];

                if (!in_array($proxy_protocol, $allowedProtocolls)) {
                    throw new Exception(
                        'Invalid/unsupported value "' . $proxy_protocol . '" for option "ProxyProtocol".',
                        Exception::INVALID_OPTION
                    );
                }
            } else {
                $proxy_protocol = StreamCreator::PROXY_PROTOCOL_HTTP;
            }

            $proxy_port = $this->loader->getOption('ProxyPort');

            // set basic proxy options
            curl_setopt($this->resource, CURLOPT_PROXY, $proxy_protocol . '://' . $proxy_host);
            if (null !== $proxy_port) {
                curl_setopt($this->resource, CURLOPT_PROXYPORT, $proxy_port);
            }

            // check auth settings
            $proxy_user = $this->loader->getOption('ProxyUser');

            // set proxy auth options
            if (null !== $proxy_user) {
                $proxy_password = $this->loader->getOption('ProxyPassword');

                $proxy_auth = $this->loader->getOption('ProxyAuth');
                if (null !== $proxy_auth) {
                    $allowedAuth = [StreamCreator::PROXY_AUTH_BASIC, StreamCreator::PROXY_AUTH_NTLM];

                    if (!in_array($proxy_auth, $allowedAuth)) {
                        throw new Exception(
                            'Invalid/unsupported value "' . $proxy_auth . '" for option "ProxyAuth".',
                            Exception::INVALID_OPTION
                        );
                    }
                } else {
                    $proxy_auth = StreamCreator::PROXY_AUTH_BASIC;
                }

                if (StreamCreator::PROXY_AUTH_NTLM === $proxy_auth) {
                    curl_setopt($this->resource, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
                }
                curl_setopt($this->resource, CURLOPT_PROXYUSERPWD, $proxy_user . ':' . $proxy_password);
            }
        }
    }
private function init(string $url): void
    {
        $this->resource = curl_init($url);

        curl_setopt($this->resource, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->resource, CURLOPT_CONNECTTIMEOUT, $this->loader->getTimeout());
        curl_setopt($this->resource, CURLOPT_USERAGENT, $this->loader->getUserAgent());
        curl_setopt($this->resource, CURLOPT_HEADER, true);
        curl_setopt($this->resource, CURLINFO_HEADER_OUT, true);

        // check and set proxy settings
        $proxy_host = $this->loader->getOption('ProxyHost');

        if (null !== $proxy_host) {
            // check for supported protocol
            $proxy_protocol = $this->loader->getOption('ProxyProtocol');

            if (null !== $proxy_protocol) {
                $allowedProtocolls = [StreamCreator::PROXY_PROTOCOL_HTTP, StreamCreator::PROXY_PROTOCOL_HTTPS];

                if (!in_array($proxy_protocol, $allowedProtocolls)) {
                    throw new Exception(
                        'Invalid/unsupported value "' . $proxy_protocol . '" for option "ProxyProtocol".',
                        Exception::INVALID_OPTION
                    );
                }
            } else {
                $proxy_protocol = StreamCreator::PROXY_PROTOCOL_HTTP;
            }

            $proxy_port = $this->loader->getOption('ProxyPort');

            // set basic proxy options
            curl_setopt($this->resource, CURLOPT_PROXY, $proxy_protocol . '://' . $proxy_host);
            if (null !== $proxy_port) {
                curl_setopt($this->resource, CURLOPT_PROXYPORT, $proxy_port);
            }

            // check auth settings
            $proxy_user = $this->loader->getOption('ProxyUser');

            // set proxy auth options
            if (null !== $proxy_user) {
                $proxy_password = $this->loader->getOption('ProxyPassword');

                $proxy_auth = $this->loader->getOption('ProxyAuth');
                if (null !== $proxy_auth) {
                    $allowedAuth = [StreamCreator::PROXY_AUTH_BASIC, StreamCreator::PROXY_AUTH_NTLM];

                    if (!in_array($proxy_auth, $allowedAuth)) {
                        throw new Exception(
                            'Invalid/unsupported value "' . $proxy_auth . '" for option "ProxyAuth".',
                            Exception::INVALID_OPTION
                        );
                    }
                } else {
                    $proxy_auth = StreamCreator::PROXY_AUTH_BASIC;
                }

                if (StreamCreator::PROXY_AUTH_NTLM === $proxy_auth) {
                    curl_setopt($this->resource, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
                }
                curl_setopt($this->resource, CURLOPT_PROXYUSERPWD, $proxy_user . ':' . $proxy_password);
            }
        }
    }
private function init ( string $ url ) : void { $ this -> resource = curl_init ( $ url ) ; curl_setopt ( $ this -> resource , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ this -> resource , CURLOPT_CONNECTTIMEOUT , $ this -> loader -> getTimeout ( ) ) ; curl_setopt ( $ this -> resource , CURLOPT_USERAGENT , $ this -> loader -> getUserAgent ( ) ) ; curl_setopt ( $ this -> resource , CURLOPT_HEADER , true ) ; curl_setopt ( $ this -> resource , CURLINFO_HEADER_OUT , true ) ; // check and set proxy settings $ proxy_host = $ this -> loader -> getOption ( 'ProxyHost' ) ; if ( null !== $ proxy_host ) { // check for supported protocol $ proxy_protocol = $ this -> loader -> getOption ( 'ProxyProtocol' ) ; if ( null !== $ proxy_protocol ) { $ allowedProtocolls = [ StreamCreator :: PROXY_PROTOCOL_HTTP , StreamCreator :: PROXY_PROTOCOL_HTTPS ] ; if ( ! in_array ( $ proxy_protocol , $ allowedProtocolls ) ) { throw new Exception ( 'Invalid/unsupported value "' . $ proxy_protocol . '" for option "ProxyProtocol".' , Exception :: INVALID_OPTION ) ; } } else { $ proxy_protocol = StreamCreator :: PROXY_PROTOCOL_HTTP ; } $ proxy_port = $ this -> loader -> getOption ( 'ProxyPort' ) ; // set basic proxy options curl_setopt ( $ this -> resource , CURLOPT_PROXY , $ proxy_protocol . '://' . $ proxy_host ) ; if ( null !== $ proxy_port ) { curl_setopt ( $ this -> resource , CURLOPT_PROXYPORT , $ proxy_port ) ; } // check auth settings $ proxy_user = $ this -> loader -> getOption ( 'ProxyUser' ) ; // set proxy auth options if ( null !== $ proxy_user ) { $ proxy_password = $ this -> loader -> getOption ( 'ProxyPassword' ) ; $ proxy_auth = $ this -> loader -> getOption ( 'ProxyAuth' ) ; if ( null !== $ proxy_auth ) { $ allowedAuth = [ StreamCreator :: PROXY_AUTH_BASIC , StreamCreator :: PROXY_AUTH_NTLM ] ; if ( ! in_array ( $ proxy_auth , $ allowedAuth ) ) { throw new Exception ( 'Invalid/unsupported value "' . $ proxy_auth . '" for option "ProxyAuth".' , Exception :: INVALID_OPTION ) ; } } else { $ proxy_auth = StreamCreator :: PROXY_AUTH_BASIC ; } if ( StreamCreator :: PROXY_AUTH_NTLM === $ proxy_auth ) { curl_setopt ( $ this -> resource , CURLOPT_PROXYAUTH , CURLAUTH_NTLM ) ; } curl_setopt ( $ this -> resource , CURLOPT_PROXYUSERPWD , $ proxy_user . ':' . $ proxy_password ) ; } } }
initialize the connection

@param string $url

@throws \FileLoader\Exception

@return void
initialize the connection