Ticket #4779: 4779.fix.reversed.encode.diff

File 4779.fix.reversed.encode.diff, 1.1 KB (added by DD32, 5 years ago)
Line 
1Index: wp-includes/http.php
2===================================================================
3--- wp-includes/http.php        (revision 8543)
4+++ wp-includes/http.php        (working copy)
5@@ -185,23 +185,25 @@
6 
7                $r = wp_parse_args( $args, $defaults );
8 
9-               if ( ! is_null($headers) && ! is_array($headers) ) {
10+               if ( is_null($headers) )
11+                       $headers = array();
12+
13+               if ( ! is_array($headers) ) {
14                        $processedHeaders = WP_Http::processHeaders($headers);
15                        $headers = $processedHeaders['headers'];
16-               } else {
17-                       $headers = array();
18                }
19 
20                if ( ! isset($headers['user-agent']) || ! isset($headers['User-Agent']) )
21                        $headers['user-agent'] = $r['user-agent'];
22 
23                if ( is_null($body) ) {
24+                       $transports = WP_Http::_getTransport();
25+               } else {
26                        if ( is_array($body) || is_object($body) )
27                                $body = http_build_query($body);
28 
29-                       $transports = WP_Http::_getTransport();
30-               } else
31                        $transports = WP_Http::_postTransport();
32+               }
33 
34                $response = array( 'headers' => array(), 'body' => '', 'response' => array('code', 'message') );
35                foreach( (array) $transports as $transport ) {