Ticket #4779: 4779.r8620.diff

File 4779.r8620.diff, 22.0 KB (added by santosj, 5 years ago)

Patch merges headers and body into $args, also adds support for chunked transfer-encoding decoding, based off of r8620

Line 
1Index: http.php
2===================================================================
3--- http.php    (revision 8620)
4+++ http.php    (working copy)
5@@ -137,6 +137,12 @@
6        /**
7         * Send a HTTP request to a URI.
8         *
9+        * The body and headers are part of the arguments. The 'body' argument is
10+        * for the body and will accept either a string or an array. The 'headers'
11+        * argument should be an array, but a string is acceptable. If the 'body'
12+        * argument is an array, then it will automatically be escaped using
13+        * http_build_query().
14+        *
15         * The only URI that are supported in the HTTP Transport implementation are
16         * the HTTP and HTTPS protocols. HTTP and HTTPS are assumed so the server
17         * might not know how to handle the send headers. Other protocols are
18@@ -171,24 +177,23 @@
19         *
20         * @param string $url URI resource.
21         * @param str|array $args Optional. Override the defaults.
22-        * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
23-        * @param string $body Optional. The body that should be sent. Will be automatically escaped and processed.
24         * @return boolean
25         */
26-       function request($url, $args = array(), $headers = null, $body = null) {
27+       function request( $url, $args = array() ) {
28                global $wp_version;
29 
30                $defaults = array(
31                        'method' => 'GET', 'timeout' => apply_filters('http_request_timeout', 3),
32                        'redirection' => 5, 'httpversion' => '1.0',
33                        'user-agent' => apply_filters('http_headers_useragent', 'WordPress/' . $wp_version ),
34-                       'blocking' => true
35+                       'blocking' => true,
36+                       'headers' => array(), 'body' => null
37                );
38 
39                $r = wp_parse_args( $args, $defaults );
40 
41-               if ( is_null($headers) )
42-                       $headers = array();
43+               if ( is_null( $r['headers'] ) )
44+                       $r['headers'] = array();
45 
46                if ( ! is_array($headers) ) {
47                        $processedHeaders = WP_Http::processHeaders($headers);
48@@ -196,25 +201,25 @@
49                }
50 
51                if ( isset($headers['User-Agent']) ) {
52-                       $headers['user-agent'] = $headers['User-Agent'];
53+                       $r['user-agent'] = $headers['User-Agent'];
54                        unset($headers['User-Agent']);
55                }
56 
57-               if ( ! isset($headers['user-agent']) )
58-                       $headers['user-agent'] = $r['user-agent'];
59+               if ( isset($headers['user-agent']) )
60+                       $r['user-agent'] = $headers['user-agent'];
61 
62-               if ( is_null($body) ) {
63+               if ( is_null($r['body']) ) {
64                        $transports = WP_Http::_getTransport();
65                } else {
66-                       if ( is_array($body) || is_object($body) )
67-                               $body = http_build_query($body);
68+                       if ( is_array( $r['body'] ) || is_object( $r['body'] ) )
69+                               $r['body'] = http_build_query($r['body']);
70 
71                        $transports = WP_Http::_postTransport();
72                }
73 
74                $response = array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
75                foreach( (array) $transports as $transport ) {
76-                       $response = $transport->request($url, $r, $headers, $body);
77+                       $response = $transport->request($url, $r);
78 
79                        if( !is_wp_error($response) )
80                                return $response;
81@@ -233,14 +238,12 @@
82         *
83         * @param string $url URI resource.
84         * @param str|array $args Optional. Override the defaults.
85-        * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
86-        * @param string $body Optional. The body that should be sent. Expected to be already processed.
87         * @return boolean
88         */
89-       function post($url, $args = array(), $headers = null, $body = null) {
90+       function post($url, $args = array()) {
91                $defaults = array('method' => 'POST');
92                $r = wp_parse_args( $args, $defaults );
93-               return $this->request($url, $r, $headers, $body);
94+               return $this->request($url, $r);
95        }
96 
97        /**
98@@ -253,14 +256,12 @@
99         *
100         * @param string $url URI resource.
101         * @param str|array $args Optional. Override the defaults.
102-        * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
103-        * @param string $body Optional. The body that should be sent. Expected to be already processed.
104         * @return boolean
105         */
106-       function get($url, $args = array(), $headers = null, $body = null) {
107+       function get($url, $args = array()) {
108                $defaults = array('method' => 'GET');
109                $r = wp_parse_args( $args, $defaults );
110-               return $this->request($url, $r, $headers, $body);
111+               return $this->request($url, $r);
112        }
113 
114        /**
115@@ -273,14 +274,12 @@
116         *
117         * @param string $url URI resource.
118         * @param str|array $args Optional. Override the defaults.
119-        * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
120-        * @param string $body Optional. The body that should be sent. Expected to be already processed.
121         * @return boolean
122         */
123-       function head($url, $args = array(), $headers = null, $body = null) {
124+       function head($url, $args = array()) {
125                $defaults = array('method' => 'HEAD');
126                $r = wp_parse_args( $args, $defaults );
127-               return $this->request($url, $r, $headers, $body);
128+               return $this->request($url, $r);
129        }
130 
131        /**
132@@ -299,40 +298,6 @@
133        }
134 
135        /**
136-        * Whether response code is in the 400 range.
137-        *
138-        * @access public
139-        * @static
140-        * @since 2.7
141-        *
142-        * @param array $response Array with code and message keys
143-        * @return bool True if 40x Response, false if something else.
144-        */
145-       function is400Response($response) {
146-               if ( (int) substr($response, 0, 1) == 4 )
147-                       return true;
148-               return false;
149-       }
150-
151-       /**
152-        * Whether the headers returned a redirect location.
153-        *
154-        * Actually just checks whether the location header exists.
155-        *
156-        * @access public
157-        * @static
158-        * @since 2.7
159-        *
160-        * @param array $headers Array with headers
161-        * @return bool True if Location header is found.
162-        */
163-       function isRedirect($headers) {
164-               if ( isset($headers['location']) )
165-                       return true;
166-               return false;
167-       }
168-
169-       /**
170         * Transform header string into an array.
171         *
172         * If an array is given then it is assumed to be raw header data with
173@@ -357,7 +322,6 @@
174                        if ( empty($tempheader) )
175                                continue;
176 
177-
178                        if ( false === strpos($tempheader, ':') ) {
179                                list( , $iResponseCode, $strResponseMsg) = explode(' ', $tempheader, 3);
180                                $response['code'] = $iResponseCode;
181@@ -373,6 +337,61 @@
182 
183                return array('response' => $response, 'headers' => $newheaders);
184        }
185+
186+       /**
187+        * Decodes chunk transfer-encoding, based off the HTTP 1.1 specification.
188+        *
189+        * Based off the HTTP http_encoding_dechunk function. Does not support
190+        * UTF-8. Does not support returning footer headers. Shouldn't be too
191+        * difficult to support it though.
192+        *
193+        * @todo Add support for footer chunked headers.
194+        *
195+        * @static
196+        * @param string $body Body content
197+        * @return bool|string|WP_Error False if not chunked encoded. WP_Error on failure. Chunked decoded body on success.
198+        */
199+       function chunkTransferDecode($body) {
200+               $body = str_replace(array("\r\n", "\r"), "\n", $body);
201+               // The body is not chunked encoding or is malformed.
202+               if ( ! preg_match( '/^[0-9a-f]+(\s|\n)+/mi', trim($body) ) )
203+                       return false;
204+
205+               $hex = '';
206+               $dec = 0;
207+               $parsedBody = '';
208+               $parsedHeaders = array();
209+
210+               $done = false;
211+
212+               do {
213+                       $hasChunk = (bool) preg_match( '/^([0-9a-f]+)(\s|\n)+/mi', $body, $match );
214+
215+                       if ( $hasChunk ) {
216+                               if ( empty($match[1]) ) {
217+                                       return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
218+                               }
219+
220+                               $length = hexdec( $match[1] );
221+                               $chunkLength = strlen( $match[0] );
222+
223+                               if( $body{$length+$chunkLength} == "\n" )
224+                                       $length++;
225+
226+                               $strBody = substr($body, strlen( $match[0] ), $length);
227+                               $parsedBody .= $strBody;
228+                               $body = str_replace(array($match[0], $strBody), '', $body);
229+
230+                               if( "0" == $body ) {
231+                                       $done = true;
232+                                       return $parsedBody; // Ignore footer headers.
233+                                       break;
234+                               }
235+                       } else {
236+                               return new WP_Error('http_chunked_decode', __('Does not appear to be chunked encoded or body is malformed.') );
237+                       }
238+               } while ( false === $done );
239+       }
240 }
241 
242 /**
243@@ -391,25 +410,32 @@
244         *
245         * Does not support non-blocking mode.
246         *
247-        * @see WP_Http::retrieve For default options descriptions.
248+        * @see WP_Http::request For default options descriptions.
249         *
250         * @since 2.7
251         * @access public
252         * @param string $url URI resource.
253         * @param str|array $args Optional. Override the defaults.
254-        * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
255-        * @param string $body Optional. The body that should be sent. Expected to be already processed.
256         * @return array 'headers', 'body', and 'response' keys.
257         */
258-       function request($url, $args = array(), $headers = null, $body = null) {
259+       function request($url, $args = array()) {
260                $defaults = array(
261                        'method' => 'GET', 'timeout' => 3,
262                        'redirection' => 5, 'httpversion' => '1.0',
263-                       'blocking' => true
264+                       'blocking' => true,
265+                       'headers' => array(), 'body' => null
266                );
267 
268                $r = wp_parse_args( $args, $defaults );
269 
270+               if ( isset($r['headers']['User-Agent']) ) {
271+                       $r['user-agent'] = $r['headers']['User-Agent'];
272+                       unset($r['headers']['User-Agent']);
273+               } else if( isset($r['headers']['user-agent']) ) {
274+                       $r['user-agent'] = $r['headers']['user-agent'];
275+                       unset($r['headers']['user-agent']);
276+               }
277+
278                $iError = null; // Store error number
279                $strError = null; // Store error string
280 
281@@ -445,22 +471,26 @@
282                $strHeaders = '';
283                $strHeaders .= strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
284                $strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
285-               if ( ! is_null($body) ) {
286+
287+               if( isset($r['user-agent']) )
288+                       $strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n";
289+
290+               if ( ! is_null($r['body']) ) {
291                        $strHeaders .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
292                        $strHeaders .= 'Content-Length: ' . strlen($body) . "\r\n";
293                }
294 
295-               if ( is_array($headers) ) {
296-                       foreach ( (array) $headers as $header => $headerValue )
297+               if ( is_array($r['headers']) ) {
298+                       foreach ( (array) $r['headers'] as $header => $headerValue )
299                                $strHeaders .= $header . ': ' . $headerValue . "\r\n";
300                } else {
301-                       $strHeaders .= $headers;
302+                       $strHeaders .= $r['headers'];
303                }
304 
305                $strHeaders .= "\r\n";
306 
307-               if ( ! is_null($body) )
308-                       $strHeaders .= $body;
309+               if ( ! is_null($r['body']) )
310+                       $strHeaders .= $r['body'];
311 
312                fwrite($handle, $strHeaders);
313 
314@@ -481,12 +511,14 @@
315                $process = WP_Http::processResponse($strResponse);
316                $arrHeaders = WP_Http::processHeaders($process['headers']);
317 
318-               if ( WP_Http::is400Response($arrHeaders['response']) )
319+               if ( WP_Http_Fsockopen::is400Response($arrHeaders['response']) )
320                        return new WP_Error('http_request_failed', $arrHeaders['response']['code'] . ': ' . $arrHeaders['response']['message']);
321 
322+               // If location is found, then assume redirect and redirect to location.
323                if ( isset($arrHeaders['headers']['location']) ) {
324-                       if ( $r['redirection']-- > 0 )
325-                               return $this->request($arrHeaders['headers']['location'], $r, $headers, $body);
326+                       if ( $r['redirection']-- > 0 ) {
327+                               return $this->request($arrHeaders['headers']['location'], $r);
328+                       }
329                        else
330                                return new WP_Error('http_request_failed', __('Too many redirects.'));
331                }
332@@ -507,6 +539,22 @@
333 
334                return false;
335        }
336+
337+       /**
338+        * Whether response code is in the 400 range.
339+        *
340+        * @access public
341+        * @static
342+        * @since 2.7
343+        *
344+        * @param array $response Array with code and message keys
345+        * @return bool True if 40x Response, false if something else.
346+        */
347+       function is400Response($response) {
348+               if ( is_string($response) && (int) substr($response, 0, 1) == 4 )
349+                       return true;
350+               return false;
351+       }
352 }
353 
354 /**
355@@ -536,17 +584,16 @@
356         *
357         * @param string $url URI resource.
358         * @param str|array $args Optional. Override the defaults.
359-        * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
360-        * @param string $body Optional. The body that should be sent. Expected to be already processed.
361         * @return array 'headers', 'body', and 'response' keys.
362         */
363-       function request($url, $args = array(), $headers = null, $body = null) {
364+       function request($url, $args = array()) {
365                global $http_response_header;
366 
367                $defaults = array(
368                        'method' => 'GET', 'timeout' => 3,
369                        'redirection' => 5, 'httpversion' => '1.0',
370-                       'blocking' => true
371+                       'blocking' => true,
372+                       'headers' => array(), 'body' => null
373                );
374 
375                $r = wp_parse_args( $args, $defaults );
376@@ -591,6 +638,9 @@
377 
378                $processedHeaders = WP_Http::processHeaders($theHeaders);
379 
380+               if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
381+                       $theBody = WP_Http::chunkTransferDecode($strResponse);
382+
383                return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']);
384        }
385 
386@@ -629,27 +679,24 @@
387         *
388         * @param string $url
389         * @param str|array $args Optional. Override the defaults.
390-        * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
391-        * @param string $body Optional. The body that should be sent. Expected to be already processed.
392         * @return array 'headers', 'body', and 'response' keys.
393         */
394-       function request($url, $args = array(), $headers = null, $body = null) {
395+       function request($url, $args = array()) {
396                $defaults = array(
397                        'method' => 'GET', 'timeout' => 3,
398                        'redirection' => 5, 'httpversion' => '1.0',
399-                       'blocking' => true
400+                       'blocking' => true,
401+                       'headers' => array(), 'body' => null
402                );
403 
404                $r = wp_parse_args( $args, $defaults );
405 
406-               if ( isset($headers['User-Agent']) ) {
407-                       $r['user-agent'] = $headers['User-Agent'];
408-                       unset($headers['User-Agent']);
409-               } else if( isset($headers['user-agent']) ) {
410-                       $r['user-agent'] = $headers['user-agent'];
411-                       unset($headers['user-agent']);
412-               } else {
413-                       $r['user-agent'] = apply_filters('http_headers_useragent', 'WordPress/' . $wp_version );
414+               if ( isset($r['headers']['User-Agent']) ) {
415+                       $r['user-agent'] = $r['headers']['User-Agent'];
416+                       unset($r['headers']['User-Agent']);
417+               } else if( isset($r['headers']['user-agent']) ) {
418+                       $r['user-agent'] = $r['headers']['user-agent'];
419+                       unset($r['headers']['user-agent']);
420                }
421 
422                $arrURL = parse_url($url);
423@@ -666,13 +713,13 @@
424                                'user-agent' => $r['user-agent'],
425                                'max_redirects' => $r['redirection'],
426                                'protocol_version' => (float) $r['httpversion'],
427-                               'header' => $headers,
428+                               'header' => $r['headers'],
429                                'timeout' => $r['timeout']
430                        )
431                );
432 
433-               if ( ! is_null($body) )
434-                       $arrContext['http']['content'] = $body;
435+               if ( ! is_null($r['body']) )
436+                       $arrContext['http']['content'] = $r['body'];
437 
438                $context = stream_context_create($arrContext);
439 
440@@ -695,6 +742,9 @@
441                $meta = stream_get_meta_data($handle);
442                $processedHeaders = WP_Http::processHeaders($meta['wrapper_data']);
443 
444+               if ( ! empty( $strResponse ) && isset( $processedHeaders['headers']['transfer-encoding'] ) && 'chunked' == $processedHeaders['headers']['transfer-encoding'] )
445+                       $theBody = WP_Http::chunkTransferDecode($strResponse);
446+
447                fclose($handle);
448 
449                return array('headers' => $processedHeaders['headers'], 'body' => $strResponse, 'response' => $processedHeaders['response']);
450@@ -743,29 +793,24 @@
451         *
452         * @param string $url
453         * @param str|array $args Optional. Override the defaults.
454-        * @param array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
455-        * @param string $body Optional. The body that should be sent. Expected to be already processed.
456         * @return array 'headers', 'body', and 'response' keys.
457         */
458-       function request($url, $args = array(), $headers = null, $body = null) {
459-               global $wp_version;
460-
461+       function request($url, $args = array()) {
462                $defaults = array(
463                        'method' => 'GET', 'timeout' => 3,
464                        'redirection' => 5, 'httpversion' => '1.0',
465-                       'blocking' => true
466+                       'blocking' => true,
467+                       'headers' => array(), 'body' => null
468                );
469 
470                $r = wp_parse_args( $args, $defaults );
471 
472-               if ( isset($headers['User-Agent']) ) {
473-                       $r['user-agent'] = $headers['User-Agent'];
474-                       unset($headers['User-Agent']);
475-               } else if( isset($headers['user-agent']) ) {
476-                       $r['user-agent'] = $headers['user-agent'];
477-                       unset($headers['user-agent']);
478-               } else {
479-                       $r['user-agent'] = apply_filters('http_headers_useragent', 'WordPress/' . $wp_version );
480+               if ( isset($r['headers']['User-Agent']) ) {
481+                       $r['user-agent'] = $r['headers']['User-Agent'];
482+                       unset($r['headers']['User-Agent']);
483+               } else if( isset($r['headers']['user-agent']) ) {
484+                       $r['user-agent'] = $r['headers']['user-agent'];
485+                       unset($r['headers']['user-agent']);
486                }
487 
488                switch ( $r['method'] ) {
489@@ -792,10 +837,10 @@
490                        'connecttimeout' => $r['timeout'],
491                        'redirect' => $r['redirection'],
492                        'useragent' => $r['user-agent'],
493-                       'headers' => $headers,
494+                       'headers' => $r['headers'],
495                );
496 
497-               $strResponse = http_request($r['method'], $url, $body, $options, $info);
498+               $strResponse = http_request($r['method'], $url, $r['body'], $options, $info);
499 
500                if ( false === $strResponse )
501                        return new WP_Error('http_request_failed', $info['response_code'] . ': ' . $info['error']);
502@@ -850,29 +895,24 @@
503         *
504         * @param string $url
505         * @param str|array $args Optional. Override the defaults.
506-        * @param string|array $headers Optional. Either the header string or array of Header name and value pairs. Expects sanitized.
507-        * @param string $body Optional. The body that should be sent. Expected to be already processed.
508         * @return array 'headers', 'body', and 'response' keys.
509         */
510-       function request($url, $args = array(), $headers = null, $body = null) {
511-               global $wp_version;
512-
513+       function request($url, $args = array()) {
514                $defaults = array(
515                        'method' => 'GET', 'timeout' => 3,
516                        'redirection' => 5, 'httpversion' => '1.0',
517-                       'blocking' => true
518+                       'blocking' => true,
519+                       'headers' => array(), 'body' => null
520                );
521 
522                $r = wp_parse_args( $args, $defaults );
523 
524-               if ( isset($headers['User-Agent']) ) {
525-                       $r['user-agent'] = $headers['User-Agent'];
526-                       unset($headers['User-Agent']);
527-               } else if( isset($headers['user-agent']) ) {
528-                       $r['user-agent'] = $headers['user-agent'];
529-                       unset($headers['user-agent']);
530-               } else {
531-                       $r['user-agent'] = apply_filters('http_headers_useragent', 'WordPress/' . $wp_version );
532+               if ( isset($r['headers']['User-Agent']) ) {
533+                       $r['user-agent'] = $r['headers']['User-Agent'];
534+                       unset($r['headers']['User-Agent']);
535+               } else if( isset($r['headers']['user-agent']) ) {
536+                       $r['user-agent'] = $r['headers']['user-agent'];
537+                       unset($r['headers']['user-agent']);
538                }
539 
540                $handle = curl_init();
541@@ -896,8 +936,8 @@
542                if ( !ini_get('safe_mode') && !ini_get('open_basedir') )
543                        curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true );
544 
545-               if( ! is_null($headers) )
546-                       curl_setopt( $handle, CURLOPT_HTTPHEADER, $headers );
547+               if( ! is_null($r['headers']) )
548+                       curl_setopt( $handle, CURLOPT_HTTPHEADER, $r['headers'] );
549 
550                if ( $r['httpversion'] == '1.0' )
551                        curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0 );
552@@ -915,6 +955,9 @@
553                list($theHeaders, $theBody) = explode("\r\n\r\n", $theResponse, 2);
554                $theHeaders = WP_Http::processHeaders($theHeaders);
555 
556+               if ( ! empty( $theBody ) && isset( $theHeaders['headers']['transfer-encoding'] ) && 'chunked' == $theHeaders['headers']['transfer-encoding'] )
557+                       $theBody = WP_Http::chunkTransferDecode($theBody);
558+
559                $response = array();
560                $response['code'] = curl_getinfo( $handle, CURLINFO_HTTP_CODE );
561                $response['message'] = get_status_header_desc($response['code']);
562@@ -986,14 +1029,11 @@
563  *
564  * @param string $url Site URL to retrieve.
565  * @param array $args Optional. Override the defaults.
566- * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
567- * @param string $body Optional. The body that should be sent. Expected to be already processed.
568  * @return string The body of the response
569  */
570-function wp_remote_request($url, $args = array(), $headers = null, $body = null) {
571+function wp_remote_request($url, $args = array()) {
572        $objFetchSite = _wp_http_get_object();
573-
574-       return $objFetchSite->request($url, $args, $headers, $body);
575+       return $objFetchSite->request($url, $args);
576 }
577 
578 /**
579@@ -1005,14 +1045,12 @@
580  *
581  * @param string $url Site URL to retrieve.
582  * @param array $args Optional. Override the defaults.
583- * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
584- * @param string $body Optional. The body that should be sent. Expected to be already processed.
585  * @return string The body of the response
586  */
587-function wp_remote_get($url, $args = array(), $headers = null, $body = null) {
588+function wp_remote_get($url, $args = array()) {
589        $objFetchSite = _wp_http_get_object();
590 
591-       return $objFetchSite->get($url, $args, $headers, $body);
592+       return $objFetchSite->get($url, $args);
593 }
594 
595 /**
596@@ -1024,14 +1062,11 @@
597  *
598  * @param string $url Site URL to retrieve.
599  * @param array $args Optional. Override the defaults.
600- * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
601- * @param string $body Optional. The body that should be sent. Expected to be already processed.
602  * @return string The body of the response
603  */
604-function wp_remote_post($url, $args = array(), $headers = null, $body = null) {
605+function wp_remote_post($url, $args = array()) {
606        $objFetchSite = _wp_http_get_object();
607-
608-       return $objFetchSite->post($url, $args, $headers, $body);
609+       return $objFetchSite->post($url, $args);
610 }
611 
612 /**
613@@ -1043,14 +1078,11 @@
614  *
615  * @param string $url Site URL to retrieve.
616  * @param array $args Optional. Override the defaults.
617- * @param string|array $headers Optional. Either the header string or array of Header name and value pairs.
618- * @param string $body Optional. The body that should be sent. Expected to be already processed.
619  * @return string The body of the response
620  */
621-function wp_remote_head($url, $args = array(), $headers = null, $body = null) {
622+function wp_remote_head($url, $args = array()) {
623        $objFetchSite = _wp_http_get_object();
624-
625-       return $objFetchSite->head($url, $args, $headers, $body);
626+       return $objFetchSite->head($url, $args);
627 }
628 
629 /**
630@@ -1136,4 +1168,4 @@
631        return $response['body'];
632 }
633 
634-?>
635+?>
636\ No newline at end of file