| 1 | Index: wp-includes/http.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/http.php (revision 10238) |
|---|
| 4 | +++ wp-includes/http.php (working copy) |
|---|
| 5 | @@ -69,11 +69,11 @@ |
|---|
| 6 | * Tests all of the objects and returns the object that passes. Also caches |
|---|
| 7 | * that object to be used later. |
|---|
| 8 | * |
|---|
| 9 | - * The order for the GET/HEAD requests are Streams, HTTP Extension, Fopen, |
|---|
| 10 | - * and finally Fsockopen. fsockopen() is used last, because it has the most |
|---|
| 11 | - * overhead in its implementation. There isn't any real way around it, since |
|---|
| 12 | - * redirects have to be supported, much the same way the other transports |
|---|
| 13 | - * also handle redirects. |
|---|
| 14 | + * The order for the GET/HEAD requests are HTTP Extension, cURL, Streams, |
|---|
| 15 | + * Fopen, and finally Fsockopen. fsockopen() is used last, because it has |
|---|
| 16 | + * the most overhead in its implementation. There isn't any real way around |
|---|
| 17 | + * it, since redirects have to be supported, much the same way the other |
|---|
| 18 | + * transports also handle redirects. |
|---|
| 19 | * |
|---|
| 20 | * There are currently issues with "localhost" not resolving correctly with |
|---|
| 21 | * DNS. This may cause an error "failed to open stream: A connection attempt |
|---|
| 22 | @@ -129,6 +129,12 @@ |
|---|
| 23 | * to send content, but the streams transport can. This is a limitation that |
|---|
| 24 | * is addressed here, by just not including that transport. |
|---|
| 25 | * |
|---|
| 26 | + * The order for the POST requests are HTTP Extension, cURL, Streams and |
|---|
| 27 | + * finally Fsockopen. fsockopen() is used last, because it has the most |
|---|
| 28 | + * overhead in its implementation. There isn't any real way around it, |
|---|
| 29 | + * since redirects have to be supported, much the same way the other |
|---|
| 30 | + * transports also handle redirects. |
|---|
| 31 | + * |
|---|
| 32 | * @since 2.7 |
|---|
| 33 | * @access private |
|---|
| 34 | * |
|---|
| 35 | @@ -142,6 +148,9 @@ |
|---|
| 36 | if ( true === WP_Http_ExtHttp::test() && apply_filters('use_http_extension_transport', true) ) { |
|---|
| 37 | $working_transport['exthttp'] = new WP_Http_ExtHttp(); |
|---|
| 38 | $blocking_transport[] = &$working_transport['exthttp']; |
|---|
| 39 | + } else if ( true === WP_Http_Curl::test() && apply_filters('use_curl_transport', true) ) { |
|---|
| 40 | + $working_transport['curl'] = new WP_Http_Curl(); |
|---|
| 41 | + $blocking_transport[] = &$working_transport['curl']; |
|---|
| 42 | } else if ( true === WP_Http_Streams::test() && apply_filters('use_streams_transport', true) ) { |
|---|
| 43 | $working_transport['streams'] = new WP_Http_Streams(); |
|---|
| 44 | $blocking_transport[] = &$working_transport['streams']; |
|---|
| 45 | @@ -215,7 +224,7 @@ |
|---|
| 46 | 'timeout' => apply_filters( 'http_request_timeout', 5), |
|---|
| 47 | 'redirection' => apply_filters( 'http_request_redirection_count', 5), |
|---|
| 48 | 'httpversion' => apply_filters( 'http_request_version', '1.0'), |
|---|
| 49 | - 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version ), |
|---|
| 50 | + 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), |
|---|
| 51 | 'blocking' => true, |
|---|
| 52 | 'headers' => array(), 'body' => null |
|---|
| 53 | ); |
|---|
| 54 | @@ -769,7 +778,8 @@ |
|---|
| 55 | 'max_redirects' => $r['redirection'], |
|---|
| 56 | 'protocol_version' => (float) $r['httpversion'], |
|---|
| 57 | 'header' => $strHeaders, |
|---|
| 58 | - 'timeout' => $r['timeout'] |
|---|
| 59 | + 'timeout' => $r['timeout'], |
|---|
| 60 | + 'verify_peer' => false |
|---|
| 61 | ) |
|---|
| 62 | ); |
|---|
| 63 | |
|---|
| 64 | @@ -899,6 +909,7 @@ |
|---|
| 65 | 'redirect' => $r['redirection'], |
|---|
| 66 | 'useragent' => $r['user-agent'], |
|---|
| 67 | 'headers' => $r['headers'], |
|---|
| 68 | + 'ssl' => array( 'verifypeer' => false, 'verifyhost' => false ) |
|---|
| 69 | ); |
|---|
| 70 | |
|---|
| 71 | if ( !defined('WP_DEBUG') || ( defined('WP_DEBUG') && false === WP_DEBUG ) ) //Emits warning level notices for max redirects and timeouts |
|---|
| 72 | @@ -988,26 +999,31 @@ |
|---|
| 73 | $r['timeout'] = 1; |
|---|
| 74 | |
|---|
| 75 | $handle = curl_init(); |
|---|
| 76 | + |
|---|
| 77 | curl_setopt( $handle, CURLOPT_URL, $url); |
|---|
| 78 | + curl_setopt( $handle, CURLOPT_RETURNTRANSFER, true ); |
|---|
| 79 | + curl_setopt( $handle, CURLOPT_SSL_VERIFYHOST, false ); |
|---|
| 80 | + curl_setopt( $handle, CURLOPT_SSL_VERIFYPEER, false ); |
|---|
| 81 | + curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); |
|---|
| 82 | + curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, $r['timeout'] ); |
|---|
| 83 | + curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); |
|---|
| 84 | + curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); |
|---|
| 85 | |
|---|
| 86 | - if ( 'HEAD' === $r['method'] ) { |
|---|
| 87 | - curl_setopt( $handle, CURLOPT_NOBODY, true ); |
|---|
| 88 | + switch ( $r['method'] ) { |
|---|
| 89 | + case 'HEAD': |
|---|
| 90 | + curl_setopt( $handle, CURLOPT_NOBODY, true ); |
|---|
| 91 | + break; |
|---|
| 92 | + case 'POST': |
|---|
| 93 | + curl_setopt( $handle, CURLOPT_POST, true ); |
|---|
| 94 | + curl_setopt( $handle, CURLOPT_POSTFIELDS, $r['body'] ); |
|---|
| 95 | + break; |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | - if ( true === $r['blocking'] ) { |
|---|
| 99 | + if ( true === $r['blocking'] ) |
|---|
| 100 | curl_setopt( $handle, CURLOPT_HEADER, true ); |
|---|
| 101 | - curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 1 ); |
|---|
| 102 | - } else { |
|---|
| 103 | + else |
|---|
| 104 | curl_setopt( $handle, CURLOPT_HEADER, false ); |
|---|
| 105 | - curl_setopt( $handle, CURLOPT_NOBODY, true ); |
|---|
| 106 | - curl_setopt( $handle, CURLOPT_RETURNTRANSFER, 0 ); |
|---|
| 107 | - } |
|---|
| 108 | |
|---|
| 109 | - curl_setopt( $handle, CURLOPT_USERAGENT, $r['user-agent'] ); |
|---|
| 110 | - curl_setopt( $handle, CURLOPT_CONNECTTIMEOUT, 1 ); |
|---|
| 111 | - curl_setopt( $handle, CURLOPT_TIMEOUT, $r['timeout'] ); |
|---|
| 112 | - curl_setopt( $handle, CURLOPT_MAXREDIRS, $r['redirection'] ); |
|---|
| 113 | - |
|---|
| 114 | if ( !ini_get('safe_mode') && !ini_get('open_basedir') ) |
|---|
| 115 | curl_setopt( $handle, CURLOPT_FOLLOWLOCATION, true ); |
|---|
| 116 | |
|---|