Changes from trunk/wp-includes/class-http.php at r17282 to branches/3.0/wp-includes/class-http.php at r15283
- File:
-
- 1 edited
-
branches/3.0/wp-includes/class-http.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/wp-includes/class-http.php
r17282 r15283 239 239 return $pre; 240 240 241 $arrURL = parse_url( $url);241 $arrURL = parse_url($url); 242 242 243 243 if ( empty( $url ) || empty( $arrURL['scheme'] ) ) … … 245 245 246 246 if ( $this->block_request( $url ) ) 247 return new WP_Error( 'http_request_failed', __( 'User has blocked requests through HTTP.' ));247 return new WP_Error('http_request_failed', __('User has blocked requests through HTTP.')); 248 248 249 249 // Determine if this is a https call and pass that on to the transport functions … … 252 252 253 253 // Determine if this request is to OUR install of WordPress 254 $homeURL = parse_url( get_bloginfo( 'url') );254 $homeURL = parse_url( get_bloginfo('url') ); 255 255 $r['local'] = $homeURL['host'] == $arrURL['host'] || 'localhost' == $arrURL['host']; 256 unset( $homeURL);256 unset($homeURL); 257 257 258 258 if ( is_null( $r['headers'] ) ) 259 259 $r['headers'] = array(); 260 260 261 if ( ! is_array( $r['headers']) ) {262 $processedHeaders = WP_Http::processHeaders( $r['headers']);261 if ( ! is_array($r['headers']) ) { 262 $processedHeaders = WP_Http::processHeaders($r['headers']); 263 263 $r['headers'] = $processedHeaders['headers']; 264 264 } 265 265 266 if ( isset( $r['headers']['User-Agent']) ) {266 if ( isset($r['headers']['User-Agent']) ) { 267 267 $r['user-agent'] = $r['headers']['User-Agent']; 268 unset( $r['headers']['User-Agent']);269 } 270 271 if ( isset( $r['headers']['user-agent']) ) {268 unset($r['headers']['User-Agent']); 269 } 270 271 if ( isset($r['headers']['user-agent']) ) { 272 272 $r['user-agent'] = $r['headers']['user-agent']; 273 unset( $r['headers']['user-agent']);273 unset($r['headers']['user-agent']); 274 274 } 275 275 … … 281 281 282 282 if ( empty($r['body']) ) { 283 $r['body'] = null;284 283 // Some servers fail when sending content without the content-length header being set. 285 284 // Also, to fix another bug, we only send when doing POST and PUT and the content-length 286 285 // header isn't already set. 287 if ( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset( $r['headers']['Content-Length']) )286 if( ($r['method'] == 'POST' || $r['method'] == 'PUT') && ! isset($r['headers']['Content-Length']) ) 288 287 $r['headers']['Content-Length'] = 0; 289 288 … … 291 290 // this case is simply that we aren't sending any bodies and to get the transports that 292 291 // don't support sending bodies along with those which do. 293 $transports = WP_Http::_getTransport( $r);292 $transports = WP_Http::_getTransport($r); 294 293 } else { 295 294 if ( is_array( $r['body'] ) || is_object( $r['body'] ) ) { 296 295 if ( ! version_compare(phpversion(), '5.1.2', '>=') ) 297 $r['body'] = _http_build_query( $r['body'], null, '&');296 $r['body'] = _http_build_query($r['body'], null, '&'); 298 297 else 299 $r['body'] = http_build_query( $r['body'], null, '&');300 $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option( 'blog_charset');301 $r['headers']['Content-Length'] = strlen( $r['body']);298 $r['body'] = http_build_query($r['body'], null, '&'); 299 $r['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=' . get_option('blog_charset'); 300 $r['headers']['Content-Length'] = strlen($r['body']); 302 301 } 303 302 304 303 if ( ! isset( $r['headers']['Content-Length'] ) && ! isset( $r['headers']['content-length'] ) ) 305 $r['headers']['Content-Length'] = strlen( $r['body']);304 $r['headers']['Content-Length'] = strlen($r['body']); 306 305 307 306 // The method is ambiguous, because we aren't talking about HTTP methods, the "post" in … … 309 308 // support sending the body. Not all do, depending on the limitations of the PHP core 310 309 // limitations. 311 $transports = WP_Http::_postTransport( $r);310 $transports = WP_Http::_postTransport($r); 312 311 } 313 312 … … 316 315 $response = array( 'headers' => array(), 'body' => '', 'response' => array('code' => false, 'message' => false), 'cookies' => array() ); 317 316 foreach ( (array) $transports as $transport ) { 318 $response = $transport->request( $url, $r);319 320 do_action( 'http_api_debug', $response, 'response', get_class( $transport) );321 322 if ( ! is_wp_error( $response) )317 $response = $transport->request($url, $r); 318 319 do_action( 'http_api_debug', $response, 'response', get_class($transport) ); 320 321 if ( ! is_wp_error($response) ) 323 322 return apply_filters( 'http_response', $response, $r, $url ); 324 323 } … … 455 454 $newheaders[$key] = trim( $value ); 456 455 } 457 if ( 'set-cookie' == $key)456 if ( 'set-cookie' == strtolower( $key ) ) 458 457 $cookies[] = new WP_Http_Cookie( $value ); 459 458 } … … 542 541 * file and this will only allow localhost and your blog to make requests. The constant 543 542 * WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests. The format of the 544 * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow, wildcard domains 545 * are supported, eg *.wordpress.org will allow for all subdomains of wordpress.org to be contacted. 543 * WP_ACCESSIBLE_HOSTS constant is a comma separated list of hostnames to allow. 546 544 * 547 545 * @since 2.8.0 548 546 * @link http://core.trac.wordpress.org/ticket/8927 Allow preventing external requests. 549 * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_ACCESSIBLE_HOSTS550 547 * 551 548 * @param string $uri URI of url. … … 581 578 582 579 static $accessible_hosts; 583 static $wildcard_regex = false; 584 if ( null == $accessible_hosts ) { 580 if ( null == $accessible_hosts ) 585 581 $accessible_hosts = preg_split('|,\s*|', WP_ACCESSIBLE_HOSTS); 586 582 587 if ( false !== strpos(WP_ACCESSIBLE_HOSTS, '*') ) { 588 $wildcard_regex = array(); 589 foreach ( $accessible_hosts as $host ) 590 $wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/')); 591 $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; 592 } 593 } 594 595 if ( !empty($wildcard_regex) ) 596 return !preg_match($wildcard_regex, $check['host']); 597 else 598 return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it. 599 600 601 583 return !in_array( $check['host'], $accessible_hosts ); //Inverse logic, If its in the array, then we can't access it. 602 584 } 603 585 } … … 640 622 $r['user-agent'] = $r['headers']['User-Agent']; 641 623 unset($r['headers']['User-Agent']); 642 } else if ( isset($r['headers']['user-agent']) ) {624 } else if( isset($r['headers']['user-agent']) ) { 643 625 $r['user-agent'] = $r['headers']['user-agent']; 644 626 unset($r['headers']['user-agent']); … … 992 974 $r['user-agent'] = $r['headers']['User-Agent']; 993 975 unset($r['headers']['User-Agent']); 994 } else if ( isset($r['headers']['user-agent']) ) {976 } else if( isset($r['headers']['user-agent']) ) { 995 977 $r['user-agent'] = $r['headers']['user-agent']; 996 978 unset($r['headers']['user-agent']); … … 1139 1121 * @since 2.7.0 1140 1122 */ 1141 class WP_Http_ExtH ttp{1123 class WP_Http_ExtHTTP { 1142 1124 /** 1143 1125 * Send a HTTP request to a URI using HTTP extension. … … 1165 1147 $r['user-agent'] = $r['headers']['User-Agent']; 1166 1148 unset($r['headers']['User-Agent']); 1167 } else if ( isset($r['headers']['user-agent']) ) {1149 } else if( isset($r['headers']['user-agent']) ) { 1168 1150 $r['user-agent'] = $r['headers']['user-agent']; 1169 1151 unset($r['headers']['user-agent']); … … 1315 1297 $r['user-agent'] = $r['headers']['User-Agent']; 1316 1298 unset($r['headers']['User-Agent']); 1317 } else if ( isset($r['headers']['user-agent']) ) {1299 } else if( isset($r['headers']['user-agent']) ) { 1318 1300 $r['user-agent'] = $r['headers']['user-agent']; 1319 1301 unset($r['headers']['user-agent']); … … 1427 1409 else 1428 1410 $theBody = ''; 1429 if ( false !== str pos($theHeaders, "\r\n\r\n") ) {1411 if ( false !== strrpos($theHeaders, "\r\n\r\n") ) { 1430 1412 $headerParts = explode("\r\n\r\n", $theHeaders); 1431 1413 $theHeaders = $headerParts[ count($headerParts) -1 ]; … … 1497 1479 * <li>WP_PROXY_BYPASS_HOSTS - Will prevent the hosts in this list from going through the proxy. 1498 1480 * You do not need to have localhost and the blog host in this list, because they will not be passed 1499 * through the proxy. The list should be presented in a comma separated list , wildcards using * are supported, eg. *.wordpress.org</li>1481 * through the proxy. The list should be presented in a comma separated list</li> 1500 1482 * </ol> 1501 1483 * … … 1504 1486 * define('WP_PROXY_HOST', '192.168.84.101'); 1505 1487 * define('WP_PROXY_PORT', '8080'); 1506 * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com , *.wordpress.org');1488 * define('WP_PROXY_BYPASS_HOSTS', 'localhost, www.example.com'); 1507 1489 * </code> 1508 1490 * 1509 1491 * @link http://core.trac.wordpress.org/ticket/4011 Proxy support ticket in WordPress. 1510 * @link http://core.trac.wordpress.org/ticket/14636 Allow wildcard domains in WP_PROXY_BYPASS_HOSTS1511 1492 * @since 2.8 1512 1493 */ … … 1625 1606 * 1626 1607 * @uses WP_PROXY_BYPASS_HOSTS 1627 * @since 2.8.01608 * @since unknown 1628 1609 * 1629 1610 * @param string $uri URI to check. … … 1648 1629 1649 1630 static $bypass_hosts; 1650 static $wildcard_regex = false; 1651 if ( null == $bypass_hosts ) { 1631 if ( null == $bypass_hosts ) 1652 1632 $bypass_hosts = preg_split('|,\s*|', WP_PROXY_BYPASS_HOSTS); 1653 1633 1654 if ( false !== strpos(WP_PROXY_BYPASS_HOSTS, '*') ) { 1655 $wildcard_regex = array(); 1656 foreach ( $bypass_hosts as $host ) 1657 $wildcard_regex[] = str_replace('\*', '[\w.]+?', preg_quote($host, '/')); 1658 $wildcard_regex = '/^(' . implode('|', $wildcard_regex) . ')$/i'; 1659 } 1660 } 1661 1662 if ( !empty($wildcard_regex) ) 1663 return !preg_match($wildcard_regex, $check['host']); 1664 else 1665 return !in_array( $check['host'], $bypass_hosts ); 1634 return !in_array( $check['host'], $bypass_hosts ); 1666 1635 } 1667 1636 }
Note: See TracChangeset
for help on using the changeset viewer.