wp/wp-includes/Requests/Proxy/HTTP.php
changeset 18 be944660c56a
parent 7 cf61fcea0001
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    57 	public function __construct($args = null) {
    57 	public function __construct($args = null) {
    58 		if (is_string($args)) {
    58 		if (is_string($args)) {
    59 			$this->proxy = $args;
    59 			$this->proxy = $args;
    60 		}
    60 		}
    61 		elseif (is_array($args)) {
    61 		elseif (is_array($args)) {
    62 			if (count($args) == 1) {
    62 			if (count($args) === 1) {
    63 				list($this->proxy) = $args;
    63 				list($this->proxy) = $args;
    64 			}
    64 			}
    65 			elseif (count($args) == 3) {
    65 			elseif (count($args) === 3) {
    66 				list($this->proxy, $this->user, $this->pass) = $args;
    66 				list($this->proxy, $this->user, $this->pass) = $args;
    67 				$this->use_authentication = true;
    67 				$this->use_authentication                    = true;
    68 			}
    68 			}
    69 			else {
    69 			else {
    70 				throw new Requests_Exception('Invalid number of arguments', 'proxyhttpbadargs');
    70 				throw new Requests_Exception('Invalid number of arguments', 'proxyhttpbadargs');
    71 			}
    71 			}
    72 		}
    72 		}
    80 	 * @see fsockopen_remote_socket
    80 	 * @see fsockopen_remote_socket
    81 	 * @see fsockopen_remote_host_path
    81 	 * @see fsockopen_remote_host_path
    82 	 * @see fsockopen_header
    82 	 * @see fsockopen_header
    83 	 * @param Requests_Hooks $hooks Hook system
    83 	 * @param Requests_Hooks $hooks Hook system
    84 	 */
    84 	 */
    85 	public function register(Requests_Hooks &$hooks) {
    85 	public function register(Requests_Hooks $hooks) {
    86 		$hooks->register('curl.before_send', array(&$this, 'curl_before_send'));
    86 		$hooks->register('curl.before_send', array($this, 'curl_before_send'));
    87 
    87 
    88 		$hooks->register('fsockopen.remote_socket', array(&$this, 'fsockopen_remote_socket'));
    88 		$hooks->register('fsockopen.remote_socket', array($this, 'fsockopen_remote_socket'));
    89 		$hooks->register('fsockopen.remote_host_path', array(&$this, 'fsockopen_remote_host_path'));
    89 		$hooks->register('fsockopen.remote_host_path', array($this, 'fsockopen_remote_host_path'));
    90 		if ($this->use_authentication) {
    90 		if ($this->use_authentication) {
    91 			$hooks->register('fsockopen.after_headers', array(&$this, 'fsockopen_header'));
    91 			$hooks->register('fsockopen.after_headers', array($this, 'fsockopen_header'));
    92 		}
    92 		}
    93 	}
    93 	}
    94 
    94 
    95 	/**
    95 	/**
    96 	 * Set cURL parameters before the data is sent
    96 	 * Set cURL parameters before the data is sent