Ticket #26049: 26049-2.patch
File 26049-2.patch, 8.6 KB (added by , 11 years ago) |
---|
-
src/wp-includes/class-http.php
69 69 70 70 $defaults = array( 71 71 'method' => 'GET', 72 /** 73 * Modifies the timeout value for the http request. 74 * 75 * @since 2.7.0 76 * 77 * @param integer $var Time in seconds until request timesout. 78 */ 72 79 'timeout' => apply_filters( 'http_request_timeout', 5), 80 /** 81 * Modifies the number of redirects allowed during the http request. 82 * 83 * @since 2.7.0 84 * 85 * @param integer $var Number of redirects allowed. 86 */ 73 87 'redirection' => apply_filters( 'http_request_redirection_count', 5), 88 /** 89 * Sets the version of the HTTP protocol used in the request. 90 * 91 * @since 2.7.0 92 * 93 * @param string $var Version of HTTP used. Acceptable values are 1.0 and 1.1. 94 */ 74 95 'httpversion' => apply_filters( 'http_request_version', '1.0'), 96 /** 97 * Modifies the user agent value sent with the http request. 98 * 99 * @since 2.7.0 100 * 101 * @param string $var User agent string. 102 */ 75 103 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), 104 /** 105 * Modifies option to run URLs through wp_http_validate_url(). 106 * 107 * @since 3.5.2 108 * 109 * @param boolean $var Option to pass URL through wp_http_validate_url(). 110 */ 76 111 'reject_unsafe_urls' => apply_filters( 'http_request_reject_unsafe_urls', false ), 77 112 'blocking' => true, 78 113 'headers' => array(), … … 95 130 $defaults['redirection'] = 0; 96 131 97 132 $r = wp_parse_args( $args, $defaults ); 133 /** 134 * Modifies arguments used in http request. 135 * 136 * @since 2.7.0 137 * 138 * @param array $r The default values parsed with arguments passed from HEAD check. 139 * @param string $url URI resource. 140 */ 98 141 $r = apply_filters( 'http_request_args', $r, $url ); 99 142 100 143 // The transports decrement this, store a copy of the original value for loop purposes. 101 144 if ( ! isset( $r['_redirection'] ) ) 102 145 $r['_redirection'] = $r['redirection']; 103 146 104 // Allow plugins to short-circuit the request 147 /** 148 * Allow plugins to set arguments for the http request. 149 * 150 * @since 2.9.0 151 * 152 * @param boolean $var Option to use arguments from plugin without further operations. 153 * @param array $r http request options. 154 * @param type $url URI Resource. 155 */ 105 156 $pre = apply_filters( 'pre_http_request', false, $r, $url ); 106 157 if ( false !== $pre ) 107 158 return $pre; … … 221 272 * @return string|bool Class name for the first transport that claims to support the request. False if no transport claims to support the request. 222 273 */ 223 274 public function _get_first_available_transport( $args, $url = null ) { 275 /** 276 * Modifies the order HTTP transports are checked. 277 * 278 * @since 3.7.0 279 * 280 * @param array $value { 281 * Establishes transports to check, in order. Default of 'curl', 'streams'. 282 * } 283 * @param array $args Request arguments. 284 * @param string $url URL to request. 285 */ 224 286 $request_order = apply_filters( 'http_api_transports', array( 'curl', 'streams' ), $args, $url ); 225 287 226 288 // Loop over each transport on each HTTP request looking for one which will serve this request's needs … … 265 327 266 328 $response = $transports[$class]->request( $url, $args ); 267 329 330 /** 331 * Fires after an HTTP API response is recieved and before the response is returned. 332 * 333 * @since 2.8.0 334 * 335 * @param array|object $response HTTP Response or WP_Error object. 336 * @param string $class HTTP transport used. 337 * @param array $args Requested arguments. 338 * @param string $url Requested URL. 339 */ 340 268 341 do_action( 'http_api_debug', $response, 'response', $class, $args, $url ); 269 342 270 343 if ( is_wp_error( $response ) ) 271 344 return $response; 272 345 346 /** 347 * Modifies the HTTP API response immediately before the response is returned. 348 * 349 * @since 2.9.0 350 * 351 * @param array|object $response HTTP Response. 352 * @param array $args Requested arguments. 353 * @param string $url Requested URL. 354 */ 273 355 return apply_filters( 'http_response', $response, $args, $url ); 274 356 } 275 357 … … 517 599 518 600 // Don't block requests back to ourselves by default 519 601 if ( $check['host'] == 'localhost' || $check['host'] == $home['host'] ) 602 /** 603 * Filter to block local requests through the proxy. 604 * 605 * @since 2.8.0 606 * 607 * @param bool $var Block local request through proxy. 608 */ 520 609 return apply_filters('block_local_requests', false); 521 610 522 611 if ( !defined('WP_ACCESSIBLE_HOSTS') ) … … 743 832 $is_local = isset( $r['local'] ) && $r['local']; 744 833 $ssl_verify = isset( $r['sslverify'] ) && $r['sslverify']; 745 834 if ( $is_local ) 835 /** 836 * Modifies if SSL should be verified for local requests. 837 * 838 * @since 2.8.0 839 * 840 * @param bool $ssl_verify Verify SSL connection. 841 */ 746 842 $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); 747 843 elseif ( ! $is_local ) 844 /** 845 * Modifies if SSL should be verified for non-local requests. 846 * 847 * @since 2.8.0 848 * 849 * @param type $ssl_verify Verify SSL connection. 850 */ 748 851 $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); 749 852 750 853 $proxy = new WP_HTTP_Proxy(); … … 1026 1129 return false; 1027 1130 } 1028 1131 1132 /** 1133 * Allows to set to false if this class can be used for retriving an URL. 1134 * 1135 * @since 2.7.0 1136 * 1137 * @param bool $var Description. 1138 * @param array $args Request arguments. 1139 */ 1029 1140 return apply_filters( 'use_streams_transport', true, $args ); 1030 1141 } 1031 1142 } … … 1146 1257 $is_local = isset($r['local']) && $r['local']; 1147 1258 $ssl_verify = isset($r['sslverify']) && $r['sslverify']; 1148 1259 if ( $is_local ) 1260 /** This filter is documented in wp-includes/class-http.php */ 1149 1261 $ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify); 1150 1262 elseif ( ! $is_local ) 1263 /** This filter is documented in wp-includes/class-http.php */ 1151 1264 $ssl_verify = apply_filters('https_ssl_verify', $ssl_verify); 1152 1265 1153 1266 // CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since … … 1225 1338 else 1226 1339 curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); 1227 1340 1228 // Cookies are not handled by the HTTP API currently. Allow for plugin authors to handle it 1229 // themselves... Although, it is somewhat pointless without some reference. 1341 /** 1342 * Fires before cURL process is executed. 1343 * 1344 * Cookies are not handled by the HTTP API currently. Allow for plugin authors to handle it themselves... Although, it is somewhat pointless without some reference. 1345 * 1346 * @since 2.8.0 1347 * 1348 * @param array $handle cURL Options set using curl_setopt. 1349 */ 1350 1230 1351 do_action_ref_array( 'http_api_curl', array(&$handle) ); 1231 1352 1232 1353 // We don't need to return the body, so don't. Just execute request and return. … … 1361 1482 return false; 1362 1483 } 1363 1484 1485 /** 1486 * Allows to set to false if this class can be used for retriving an URL. 1487 * 1488 * @since 2.7.0 1489 * 1490 * @param bool $var Description. 1491 * @param array $args Request arguments. 1492 */ 1364 1493 return apply_filters( 'use_curl_transport', true, $args ); 1365 1494 } 1366 1495 } … … 1527 1656 1528 1657 $home = parse_url( get_option('siteurl') ); 1529 1658 1659 /** 1660 * Filter to force send_through_proxy. 1661 * 1662 * @since 3.5.0 1663 * 1664 * @param string $uri URI to check. 1665 * @param array $check Associative array result of parse_url($uri). 1666 * @param array $home Associative array result of parse_url() of the siteurl. 1667 * 1668 */ 1530 1669 $result = apply_filters( 'pre_http_send_through_proxy', null, $uri, $check, $home ); 1531 1670 if ( ! is_null( $result ) ) 1532 1671 return $result; … … 1741 1880 if ( ! isset( $this->name ) || ! isset( $this->value ) ) 1742 1881 return ''; 1743 1882 1883 /** 1884 * Filters the header-encoded cookie value. 1885 * 1886 * @since 3.4.0 1887 * 1888 * @param string $this->value Cookie value. 1889 * @param string $this-name Cookie name. 1890 */ 1744 1891 return $this->name . '=' . apply_filters( 'wp_http_cookie_value', $this->value, $this->name ); 1745 1892 } 1746 1893 … … 1902 2049 $type[] = 'gzip;q=0.5'; 1903 2050 } 1904 2051 2052 /** 2053 * Modifies encoding types to allow. 2054 * 2055 * @since 3.6.0 2056 * 2057 * @param array $type Encoding types allowed. 2058 * @param string $url URL of the HTTP request. 2059 * @param array $args HTTP request arguments. 2060 */ 1905 2061 $type = apply_filters( 'wp_http_accept_encoding', $type, $url, $args ); 1906 2062 1907 2063 return implode(', ', $type);