Ticket #26049: 26049-3.patch
File 26049-3.patch, 9.5 KB (added by , 11 years ago) |
---|
-
src/wp-includes/class-http.php
69 69 70 70 $defaults = array( 71 71 'method' => 'GET', 72 'timeout' => apply_filters( 'http_request_timeout', 5), 73 'redirection' => apply_filters( 'http_request_redirection_count', 5), 74 'httpversion' => apply_filters( 'http_request_version', '1.0'), 72 /** 73 * Filter the timeout value for the HTTP request. 74 * 75 * @since 2.7.0 76 * 77 * @param int $timeout_value Time in seconds until a request times out. 78 */ 79 'timeout' => apply_filters( 'http_request_timeout', 5 ), 80 /** 81 * Filter the number of redirects allowed during the HTTP request. 82 * 83 * @since 2.7.0 84 * 85 * @param int $redirect_count Number of redirects allowed. 86 */ 87 'redirection' => apply_filters( 'http_request_redirection_count', 5 ), 88 /** 89 * Filter the version of the HTTP protocol used in the request. 90 * 91 * @since 2.7.0 92 * 93 * @param string $version Version of HTTP used. Accepts '1.0' and '1.1'. 94 */ 95 'httpversion' => apply_filters( 'http_request_version', '1.0' ), 96 /** 97 * Filter the user agent value sent with the HTTP request. 98 * 99 * @since 2.7.0 100 * 101 * @param string $user_agent User agent string. 102 */ 75 103 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), 104 /** 105 * Filter whether to pass URLs through wp_http_validate_url(). 106 * 107 * @since 3.6.0 108 * 109 * @param bool $bool Whether 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 * Filter the arguments used in an 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 * Filter the arguments for the HTTP request. 149 * 150 * @since 2.9.0 151 * 152 * @param bool $bool Whether to use arguments from a plugin without 153 * further operations. Default false. 154 * @param array $r HTTP request options. 155 * @param type $url URI Resource. 156 */ 105 157 $pre = apply_filters( 'pre_http_request', false, $r, $url ); 106 158 if ( false !== $pre ) 107 159 return $pre; … … 221 273 * @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 274 */ 223 275 public function _get_first_available_transport( $args, $url = null ) { 276 /** 277 * Filter the order HTTP transports are checked. 278 * 279 * @since 3.7.0 280 * 281 * @param array $value Establishes transports to check, in order. 282 * Default 'curl', 'streams'. 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 received and before the response is returned. 332 * 333 * @since 2.8.0 334 * 335 * @param array|obj $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 */ 268 340 do_action( 'http_api_debug', $response, 'response', $class, $args, $url ); 269 341 270 342 if ( is_wp_error( $response ) ) 271 343 return $response; 272 344 345 /** 346 * Filter the HTTP API response immediately before the response is returned. 347 * 348 * @since 2.9.0 349 * 350 * @param array|obj $response HTTP Response. 351 * @param array $args Requested arguments. 352 * @param string $url Requested URL. 353 */ 273 354 return apply_filters( 'http_response', $response, $args, $url ); 274 355 } 275 356 … … 517 598 518 599 // Don't block requests back to ourselves by default 519 600 if ( $check['host'] == 'localhost' || $check['host'] == $home['host'] ) 520 return apply_filters('block_local_requests', false); 601 /** 602 * Filter whether to block local requests through the proxy. 603 * 604 * @since 2.8.0 605 * 606 * @param bool $bool Whether to block local requests through proxy. Default false. 607 */ 608 return apply_filters( 'block_local_requests', false ); 521 609 522 610 if ( !defined('WP_ACCESSIBLE_HOSTS') ) 523 611 return true; … … 743 831 $is_local = isset( $r['local'] ) && $r['local']; 744 832 $ssl_verify = isset( $r['sslverify'] ) && $r['sslverify']; 745 833 if ( $is_local ) 834 /** 835 * Filter whether SSL should be verified for local requests. 836 * 837 * @since 2.8.0 838 * 839 * @param bool $ssl_verify Verify the SSL connection. 840 */ 746 841 $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); 747 842 elseif ( ! $is_local ) 843 /** 844 * Filter whether SSL should be verified for non-local requests. 845 * 846 * @since 2.8.0 847 * 848 * @param bool $ssl_verify Verify the SSL connection. 849 */ 748 850 $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); 749 851 750 852 $proxy = new WP_HTTP_Proxy(); … … 1026 1128 return false; 1027 1129 } 1028 1130 1131 /** 1132 * Filter whether the WP_Http_Streams class can be used for retrieving a URL. 1133 * 1134 * @since 2.7.0 1135 * 1136 * @param bool $bool Whether the class can be used. Default true. 1137 * @param array $args Request arguments. 1138 */ 1029 1139 return apply_filters( 'use_streams_transport', true, $args ); 1030 1140 } 1031 1141 } … … 1146 1256 $is_local = isset($r['local']) && $r['local']; 1147 1257 $ssl_verify = isset($r['sslverify']) && $r['sslverify']; 1148 1258 if ( $is_local ) 1149 $ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify); 1259 /** This filter is documented in wp-includes/class-http.php */ 1260 $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); 1150 1261 elseif ( ! $is_local ) 1151 $ssl_verify = apply_filters('https_ssl_verify', $ssl_verify); 1262 /** This filter is documented in wp-includes/class-http.php */ 1263 $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); 1152 1264 1153 1265 // CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since 1154 1266 // a value of 0 will allow an unlimited timeout. … … 1225 1337 else 1226 1338 curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); 1227 1339 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. 1340 /** 1341 * Fires before the cURL process is executed. 1342 * 1343 * Cookies are not currently handled by the HTTP API. This action allows 1344 * plugins to handle cookies themselves. 1345 * 1346 * @since 2.8.0 1347 * 1348 * @param array $handle cURL options set using curl_setopt. 1349 */ 1230 1350 do_action_ref_array( 'http_api_curl', array(&$handle) ); 1231 1351 1232 1352 // We don't need to return the body, so don't. Just execute request and return. … … 1361 1481 return false; 1362 1482 } 1363 1483 1484 /** 1485 * Filter whether the WP_Http_Curl class can be used for retrieving a URL. 1486 * 1487 * @since 2.7.0 1488 * 1489 * @param bool $bool Whether the class can be used. Default true. 1490 * @param array $args An array of request arguments. 1491 */ 1364 1492 return apply_filters( 'use_curl_transport', true, $args ); 1365 1493 } 1366 1494 } … … 1529 1657 1530 1658 $home = parse_url( get_option('siteurl') ); 1531 1659 1660 /** 1661 * Filter whether to force send_through_proxy. 1662 * 1663 * This filter allows a plugin to preempt the return value of 1664 * WP_HTTP_Proxy::send_through_proxy(). 1665 * 1666 * @since 3.5.0 1667 * 1668 * @param null $override_result Whether to override the result. 1669 * Return true to send through the proxy, 1670 * false to bypass the proxy. Default null. 1671 * @param string $uri URL to check. 1672 * @param array $check Associative array result of parse_url($uri). 1673 * @param array $home Associative array result of parse_url() of the siteurl. 1674 */ 1532 1675 $result = apply_filters( 'pre_http_send_through_proxy', null, $uri, $check, $home ); 1533 1676 if ( ! is_null( $result ) ) 1534 1677 return $result; … … 1743 1886 if ( ! isset( $this->name ) || ! isset( $this->value ) ) 1744 1887 return ''; 1745 1888 1889 /** 1890 * Filter the header-encoded cookie value. 1891 * 1892 * @since 3.4.0 1893 * 1894 * @param string $value The cookie value. 1895 * @param string $name The cookie name. 1896 */ 1746 1897 return $this->name . '=' . apply_filters( 'wp_http_cookie_value', $this->value, $this->name ); 1747 1898 } 1748 1899 … … 1904 2055 $type[] = 'gzip;q=0.5'; 1905 2056 } 1906 2057 2058 /** 2059 * Filter the allowed encoding types. 2060 * 2061 * @since 3.6.0 2062 * 2063 * @param array $type Encoding types allowed. Accepts 'gzinflate', 2064 * 'gzuncompress', 'gzdecode'. 2065 * @param string $url URL of the HTTP request. 2066 * @param array $args HTTP request arguments. 2067 */ 1907 2068 $type = apply_filters( 'wp_http_accept_encoding', $type, $url, $args ); 1908 2069 1909 2070 return implode(', ', $type);