@@ -39,7 +39,7 @@ function _wp_http_get_object() {
3939 * @see wp_remote_request() For more information on the response array format.
4040 * @see WP_Http::request() For default arguments information.
4141 *
42- * @param string $url Site URL to retrieve.
42+ * @param string $url URL to retrieve.
4343 * @param array $args Optional. Request arguments. Default empty array.
4444 * @return WP_Error|array The response or WP_Error on failure.
4545 */
@@ -60,7 +60,7 @@ function wp_safe_remote_request( $url, $args = array() ) {
6060 * @see wp_remote_request() For more information on the response array format.
6161 * @see WP_Http::request() For default arguments information.
6262 *
63- * @param string $url Site URL to retrieve.
63+ * @param string $url URL to retrieve.
6464 * @param array $args Optional. Request arguments. Default empty array.
6565 * @return WP_Error|array The response or WP_Error on failure.
6666 */
@@ -81,7 +81,7 @@ function wp_safe_remote_get( $url, $args = array() ) {
8181 * @see wp_remote_request() For more information on the response array format.
8282 * @see WP_Http::request() For default arguments information.
8383 *
84- * @param string $url Site URL to retrieve.
84+ * @param string $url URL to retrieve.
8585 * @param array $args Optional. Request arguments. Default empty array.
8686 * @return WP_Error|array The response or WP_Error on failure.
8787 */
@@ -102,8 +102,8 @@ function wp_safe_remote_post( $url, $args = array() ) {
102102 * @see wp_remote_request() For more information on the response array format.
103103 * @see WP_Http::request() For default arguments information.
104104 *
105- * @param string $url Site URL 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.
107107 * @return WP_Error|array The response or WP_Error on failure.
108108 */
109109function wp_safe_remote_head ( $ url , $ args = array () ) {
@@ -113,40 +113,34 @@ function wp_safe_remote_head( $url, $args = array() ) {
113113}
114114
115115/**
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.
116+ * Performs an HTTP request and returns its response.
130117 *
131- * $user_agent = $res['headers']['user-agent'];
118+ * There are other API functions available which abstract away the HTTP method:
132119 *
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:
139120 * - Default 'GET' for wp_remote_get()
140121 * - Default 'POST' for wp_remote_post()
141122 * - Default 'HEAD' for wp_remote_head()
142123 *
143124 * @since 2.7.0
144125 *
145- * @see WP_Http::request() For additional information on default arguments.
126+ * @see WP_Http::request() For information on default arguments.
146127 *
147- * @param string $url Site URL to retrieve.
128+ * @param string $url URL to retrieve.
148129 * @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+ * }
150144 */
151145function wp_remote_request ( $ url , $ args = array () ) {
152146 $ http = _wp_http_get_object ();
@@ -161,7 +155,7 @@ function wp_remote_request( $url, $args = array() ) {
161155 * @see wp_remote_request() For more information on the response array format.
162156 * @see WP_Http::request() For default arguments information.
163157 *
164- * @param string $url Site URL to retrieve.
158+ * @param string $url URL to retrieve.
165159 * @param array $args Optional. Request arguments. Default empty array.
166160 * @return WP_Error|array The response or WP_Error on failure.
167161 */
@@ -178,7 +172,7 @@ function wp_remote_get( $url, $args = array() ) {
178172 * @see wp_remote_request() For more information on the response array format.
179173 * @see WP_Http::request() For default arguments information.
180174 *
181- * @param string $url Site URL to retrieve.
175+ * @param string $url URL to retrieve.
182176 * @param array $args Optional. Request arguments. Default empty array.
183177 * @return WP_Error|array The response or WP_Error on failure.
184178 */
@@ -195,7 +189,7 @@ function wp_remote_post( $url, $args = array() ) {
195189 * @see wp_remote_request() For more information on the response array format.
196190 * @see WP_Http::request() For default arguments information.
197191 *
198- * @param string $url Site URL to retrieve.
192+ * @param string $url URL to retrieve.
199193 * @param array $args Optional. Request arguments. Default empty array.
200194 * @return WP_Error|array The response or WP_Error on failure.
201195 */
@@ -212,7 +206,7 @@ function wp_remote_head( $url, $args = array() ) {
212206 *
213207 * @see \Requests_Utility_CaseInsensitiveDictionary
214208 *
215- * @param array $response HTTP response.
209+ * @param array|WP_Error $response HTTP response.
216210 * @return array|\Requests_Utility_CaseInsensitiveDictionary The headers of the response. Empty array if incorrect parameter given.
217211 */
218212function wp_remote_retrieve_headers ( $ response ) {
@@ -228,8 +222,8 @@ function wp_remote_retrieve_headers( $response ) {
228222 *
229223 * @since 2.7.0
230224 *
231- * @param array $response
232- * @param string $header Header name to retrieve value from.
225+ * @param array|WP_Error $response HTTP response.
226+ * @param string $header Header name to retrieve value from.
233227 * @return string The header value. Empty string on if incorrect parameter given, or if the header doesn't exist.
234228 */
235229function wp_remote_retrieve_header ( $ response , $ header ) {
@@ -251,7 +245,7 @@ function wp_remote_retrieve_header( $response, $header ) {
251245 *
252246 * @since 2.7.0
253247 *
254- * @param array $response HTTP response.
248+ * @param array|WP_Error $response HTTP response.
255249 * @return int|string The response code as an integer. Empty string on incorrect parameter given.
256250 */
257251function wp_remote_retrieve_response_code ( $ response ) {
@@ -269,7 +263,7 @@ function wp_remote_retrieve_response_code( $response ) {
269263 *
270264 * @since 2.7.0
271265 *
272- * @param array $response HTTP response.
266+ * @param array|WP_Error $response HTTP response.
273267 * @return string The response message. Empty string on incorrect parameter given.
274268 */
275269function wp_remote_retrieve_response_message ( $ response ) {
@@ -285,7 +279,7 @@ function wp_remote_retrieve_response_message( $response ) {
285279 *
286280 * @since 2.7.0
287281 *
288- * @param array $response HTTP response.
282+ * @param array|WP_Error $response HTTP response.
289283 * @return string The body of the response. Empty string if no body or incorrect parameter given.
290284 */
291285function wp_remote_retrieve_body ( $ response ) {
@@ -301,8 +295,8 @@ function wp_remote_retrieve_body( $response ) {
301295 *
302296 * @since 4.4.0
303297 *
304- * @param array $response HTTP response.
305- * @return array An 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.
306300 */
307301function wp_remote_retrieve_cookies ( $ response ) {
308302 if ( is_wp_error ( $ response ) || empty ( $ response ['cookies ' ] ) ) {
@@ -317,8 +311,8 @@ function wp_remote_retrieve_cookies( $response ) {
317311 *
318312 * @since 4.4.0
319313 *
320- * @param array $response HTTP response.
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.
322316 * @return WP_Http_Cookie|string The `WP_Http_Cookie` object. Empty string if the cookie isn't present in the response.
323317 */
324318function wp_remote_retrieve_cookie ( $ response , $ name ) {
@@ -342,8 +336,8 @@ function wp_remote_retrieve_cookie( $response, $name ) {
342336 *
343337 * @since 4.4.0
344338 *
345- * @param array $response HTTP response.
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.
347341 * @return string The value of the cookie. Empty string if the cookie isn't present in the response.
348342 */
349343function wp_remote_retrieve_cookie_value ( $ response , $ name ) {
0 commit comments