wp/wp-includes/class-requests.php
changeset 16 a86126ab1dd4
parent 7 cf61fcea0001
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    86 	/**
    86 	/**
    87 	 * Current version of Requests
    87 	 * Current version of Requests
    88 	 *
    88 	 *
    89 	 * @var string
    89 	 * @var string
    90 	 */
    90 	 */
    91 	const VERSION = '1.7';
    91 	const VERSION = '1.7-3470169';
    92 
    92 
    93 	/**
    93 	/**
    94 	 * Registered transport classes
    94 	 * Registered transport classes
    95 	 *
    95 	 *
    96 	 * @var array
    96 	 * @var array
   185 		ksort($capabilities);
   185 		ksort($capabilities);
   186 		$cap_string = serialize($capabilities);
   186 		$cap_string = serialize($capabilities);
   187 
   187 
   188 		// Don't search for a transport if it's already been done for these $capabilities
   188 		// Don't search for a transport if it's already been done for these $capabilities
   189 		if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) {
   189 		if (isset(self::$transport[$cap_string]) && self::$transport[$cap_string] !== null) {
   190 			return new self::$transport[$cap_string]();
   190 			$class = self::$transport[$cap_string];
       
   191 			return new $class();
   191 		}
   192 		}
   192 		// @codeCoverageIgnoreEnd
   193 		// @codeCoverageIgnoreEnd
   193 
   194 
   194 		if (empty(self::$transports)) {
   195 		if (empty(self::$transports)) {
   195 			self::$transports = array(
   196 			self::$transports = array(
   212 		}
   213 		}
   213 		if (self::$transport[$cap_string] === null) {
   214 		if (self::$transport[$cap_string] === null) {
   214 			throw new Requests_Exception('No working transports found', 'notransport', self::$transports);
   215 			throw new Requests_Exception('No working transports found', 'notransport', self::$transports);
   215 		}
   216 		}
   216 
   217 
   217 		return new self::$transport[$cap_string]();
   218 		$class = self::$transport[$cap_string];
       
   219 		return new $class();
   218 	}
   220 	}
   219 
   221 
   220 	/**#@+
   222 	/**#@+
   221 	 * @see request()
   223 	 * @see request()
   222 	 * @param string $url
   224 	 * @param string $url
   787 
   789 
   788 	/**
   790 	/**
   789 	 * Convert a key => value array to a 'key: value' array for headers
   791 	 * Convert a key => value array to a 'key: value' array for headers
   790 	 *
   792 	 *
   791 	 * @param array $array Dictionary of header values
   793 	 * @param array $array Dictionary of header values
   792 	 * @return array List of headers
   794 	 * @return string[] List of headers
   793 	 */
   795 	 */
   794 	public static function flatten($array) {
   796 	public static function flatten($array) {
   795 		$return = array();
   797 		$return = array();
   796 		foreach ($array as $key => $value) {
   798 		foreach ($array as $key => $value) {
   797 			$return[] = sprintf('%s: %s', $key, $value);
   799 			$return[] = sprintf('%s: %s', $key, $value);
   803 	 * Convert a key => value array to a 'key: value' array for headers
   805 	 * Convert a key => value array to a 'key: value' array for headers
   804 	 *
   806 	 *
   805 	 * @codeCoverageIgnore
   807 	 * @codeCoverageIgnore
   806 	 * @deprecated Misspelling of {@see Requests::flatten}
   808 	 * @deprecated Misspelling of {@see Requests::flatten}
   807 	 * @param array $array Dictionary of header values
   809 	 * @param array $array Dictionary of header values
   808 	 * @return array List of headers
   810 	 * @return string[] List of headers
   809 	 */
   811 	 */
   810 	public static function flattern($array) {
   812 	public static function flattern($array) {
   811 		return self::flatten($array);
   813 		return self::flatten($array);
   812 	}
   814 	}
   813 
   815