use_authentication example

$handle = curl_init();

        // cURL offers really easy proxy support.         $proxy = new WP_HTTP_Proxy();

        if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {

            curl_setopt( $handle, CURLOPT_PROXYTYPE, CURLPROXY_HTTP );
            curl_setopt( $handle, CURLOPT_PROXY, $proxy->host() );
            curl_setopt( $handle, CURLOPT_PROXYPORT, $proxy->port() );

            if ( $proxy->use_authentication() ) {
                curl_setopt( $handle, CURLOPT_PROXYAUTH, CURLAUTH_ANY );
                curl_setopt( $handle, CURLOPT_PROXYUSERPWD, $proxy->authentication() );
            }
        }

        $is_local   = isset( $parsed_args['local'] ) && $parsed_args['local'];
        $ssl_verify = isset( $parsed_args['sslverify'] ) && $parsed_args['sslverify'];
        if ( $is_local ) {
            /** This filter is documented in wp-includes/class-wp-http-streams.php */
            $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify$url );
        } elseif ( ! $is_local ) {
            
$headers .= 'User-agent: ' . $parsed_args['user-agent'] . "\r\n";
        }

        if ( is_array( $parsed_args['headers'] ) ) {
            foreach ( (array) $parsed_args['headers'] as $header => $header_value ) {
                $headers .= $header . ': ' . $header_value . "\r\n";
            }
        } else {
            $headers .= $parsed_args['headers'];
        }

        if ( $proxy->use_authentication() ) {
            $headers .= $proxy->authentication_header() . "\r\n";
        }

        $headers .= "\r\n";

        if ( ! is_null( $parsed_args['body'] ) ) {
            $headers .= $parsed_args['body'];
        }

        fwrite( $handle$headers );

        

        $options['verify'] = apply_filters( 'https_ssl_verify', $options['verify']$url );

        // Check for proxies.         $proxy = new WP_HTTP_Proxy();
        if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) {
            $options['proxy'] = new WpOrg\Requests\Proxy\Http( $proxy->host() . ':' . $proxy->port() );

            if ( $proxy->use_authentication() ) {
                $options['proxy']->use_authentication = true;
                $options['proxy']->user               = $proxy->username();
                $options['proxy']->pass               = $proxy->password();
            }
        }

        // Avoid issues where mbstring.func_overload is enabled.         mbstring_binary_safe_encoding();

        try {
            $requests_response = WpOrg\Requests\Requests::request( $url$headers$data$type$options );

            
Home | Imprint | This part of the site doesn't use cookies.