Changeset 46468 for trunk/src/wp-includes/http.php
- Timestamp:
- 10/12/2019 06:03:22 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/http.php
r46424 r46468 40 40 * @see WP_Http::request() For default arguments information. 41 41 * 42 * @param string $url SiteURL to retrieve.42 * @param string $url URL to retrieve. 43 43 * @param array $args Optional. Request arguments. Default empty array. 44 44 * @return WP_Error|array The response or WP_Error on failure. … … 61 61 * @see WP_Http::request() For default arguments information. 62 62 * 63 * @param string $url SiteURL to retrieve.63 * @param string $url URL to retrieve. 64 64 * @param array $args Optional. Request arguments. Default empty array. 65 65 * @return WP_Error|array The response or WP_Error on failure. … … 82 82 * @see WP_Http::request() For default arguments information. 83 83 * 84 * @param string $url SiteURL to retrieve.84 * @param string $url URL to retrieve. 85 85 * @param array $args Optional. Request arguments. Default empty array. 86 86 * @return WP_Error|array The response or WP_Error on failure. … … 103 103 * @see WP_Http::request() For default arguments information. 104 104 * 105 * @param string $url SiteURL to retrieve.106 * @param array $args Optional. Request arguments. Default empty array.105 * @param string $url URL to retrieve. 106 * @param array $args Optional. Request arguments. Default empty array. 107 107 * @return WP_Error|array The response or WP_Error on failure. 108 108 */ … … 114 114 115 115 /** 116 * Retrieve the raw response from the HTTP request. 117 * 118 * The array structure is a little complex: 119 * 120 * $res = array( 121 * 'headers' => array(), 122 * 'response' => array( 123 * 'code' => int, 124 * 'message' => string 125 * ) 126 * ); 127 * 128 * All of the headers in $res['headers'] are with the name as the key and the 129 * value as the value. So to get the User-Agent, you would do the following. 130 * 131 * $user_agent = $res['headers']['user-agent']; 132 * 133 * The body is the raw response content and can be retrieved from $res['body']. 134 * 135 * This function is called first to make the request and there are other API 136 * functions to abstract out the above convoluted setup. 137 * 138 * Request method defaults for helper functions: 116 * Performs an HTTP request and returns its response. 117 * 118 * There are other API functions available which abstract away the HTTP method: 119 * 139 120 * - Default 'GET' for wp_remote_get() 140 121 * - Default 'POST' for wp_remote_post() … … 143 124 * @since 2.7.0 144 125 * 145 * @see WP_Http::request() For additionalinformation on default arguments.146 * 147 * @param string $url SiteURL to retrieve.126 * @see WP_Http::request() For information on default arguments. 127 * 128 * @param string $url URL to retrieve. 148 129 * @param array $args Optional. Request arguments. Default empty array. 149 * @return WP_Error|array The response or WP_Error on failure. 130 * @return WP_Error|array { 131 * The response array or a WP_Error on failure. 132 * 133 * @type string[] $headers Array of response headers keyed by their name. 134 * @type string $body Response body. 135 * @type array $response { 136 * Data about the HTTP response. 137 * 138 * @type int|false $code HTTP response code. 139 * @type string|false $message HTTP response message. 140 * } 141 * @type WP_HTTP_Cookie[] $cookies Array of response cookies. 142 * @type WP_HTTP_Requests_Response|null $http_response Raw HTTP response object. 143 * } 150 144 */ 151 145 function wp_remote_request( $url, $args = array() ) { … … 162 156 * @see WP_Http::request() For default arguments information. 163 157 * 164 * @param string $url SiteURL to retrieve.158 * @param string $url URL to retrieve. 165 159 * @param array $args Optional. Request arguments. Default empty array. 166 160 * @return WP_Error|array The response or WP_Error on failure. … … 179 173 * @see WP_Http::request() For default arguments information. 180 174 * 181 * @param string $url SiteURL to retrieve.175 * @param string $url URL to retrieve. 182 176 * @param array $args Optional. Request arguments. Default empty array. 183 177 * @return WP_Error|array The response or WP_Error on failure. … … 196 190 * @see WP_Http::request() For default arguments information. 197 191 * 198 * @param string $url SiteURL to retrieve.192 * @param string $url URL to retrieve. 199 193 * @param array $args Optional. Request arguments. Default empty array. 200 194 * @return WP_Error|array The response or WP_Error on failure. … … 213 207 * @see \Requests_Utility_CaseInsensitiveDictionary 214 208 * 215 * @param array $response HTTP response.209 * @param array|WP_Error $response HTTP response. 216 210 * @return array|\Requests_Utility_CaseInsensitiveDictionary The headers of the response. Empty array if incorrect parameter given. 217 211 */ … … 229 223 * @since 2.7.0 230 224 * 231 * @param array $response232 * @param string $headerHeader name to retrieve value from.225 * @param array|WP_Error $response HTTP response. 226 * @param string $header Header name to retrieve value from. 233 227 * @return string The header value. Empty string on if incorrect parameter given, or if the header doesn't exist. 234 228 */ … … 252 246 * @since 2.7.0 253 247 * 254 * @param array $response HTTP response.248 * @param array|WP_Error $response HTTP response. 255 249 * @return int|string The response code as an integer. Empty string on incorrect parameter given. 256 250 */ … … 270 264 * @since 2.7.0 271 265 * 272 * @param array $response HTTP response.266 * @param array|WP_Error $response HTTP response. 273 267 * @return string The response message. Empty string on incorrect parameter given. 274 268 */ … … 286 280 * @since 2.7.0 287 281 * 288 * @param array $response HTTP response.282 * @param array|WP_Error $response HTTP response. 289 283 * @return string The body of the response. Empty string if no body or incorrect parameter given. 290 284 */ … … 302 296 * @since 4.4.0 303 297 * 304 * @param array $response HTTP response.305 * @return arrayAn array of `WP_Http_Cookie` objects from the response. Empty array if there are none, or the response is a WP_Error.298 * @param array|WP_Error $response HTTP response. 299 * @return WP_Http_Cookie[] An array of `WP_Http_Cookie` objects from the response. Empty array if there are none, or the response is a WP_Error. 306 300 */ 307 301 function wp_remote_retrieve_cookies( $response ) { … … 318 312 * @since 4.4.0 319 313 * 320 * @param array 321 * @param string $name The name of the cookie to retrieve.314 * @param array|WP_Error $response HTTP response. 315 * @param string $name The name of the cookie to retrieve. 322 316 * @return WP_Http_Cookie|string The `WP_Http_Cookie` object. Empty string if the cookie isn't present in the response. 323 317 */ … … 343 337 * @since 4.4.0 344 338 * 345 * @param array 346 * @param string $name The name of the cookie to retrieve.339 * @param array|WP_Error $response HTTP response. 340 * @param string $name The name of the cookie to retrieve. 347 341 * @return string The value of the cookie. Empty string if the cookie isn't present in the response. 348 342 */
Note: See TracChangeset
for help on using the changeset viewer.