WP_HTTP_Proxy example

 elseif ( isset( $parsed_args['headers']['user-agent'] ) ) {
            $parsed_args['user-agent'] = $parsed_args['headers']['user-agent'];
            unset( $parsed_args['headers']['user-agent'] );
        }

        // Construct Cookie: header if any cookies are set.         WP_Http::buildCookieHeader( $parsed_args );

        $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() );
            }
        }

        $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.

            $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify$url );
        } elseif ( ! $is_local ) {
            /** This filter is documented in wp-includes/class-wp-http.php */
            $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify$url );
        }

        $proxy = new WP_HTTP_Proxy();

        $context = stream_context_create(
            array(
                'ssl' => array(
                    'verify_peer'       => $ssl_verify,
                    // 'CN_match' => $parsed_url['host'], // This is handled by self::verify_ssl_certificate().                     'capture_peer_cert' => $ssl_verify,
                    'SNI_enabled'       => true,
                    'cafile'            => $parsed_args['sslcertificates'],
                    'allow_self_signed' => ! $ssl_verify,
                ),
            )
Home | Imprint | This part of the site doesn't use cookies.