Changeset 27049
- Timestamp:
- 01/28/2014 08:25:00 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-http.php
r26868 r27049 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 an HTTP request. 74 * 75 * @since 2.7.0 76 * 77 * @param int $timeout_value Time in seconds until a request times out. 78 * Default 5. 79 */ 80 'timeout' => apply_filters( 'http_request_timeout', 5 ), 81 /** 82 * Filter the number of redirects allowed during an HTTP request. 83 * 84 * @since 2.7.0 85 * 86 * @param int $redirect_count Number of redirects allowed. Default 5. 87 */ 88 'redirection' => apply_filters( 'http_request_redirection_count', 5 ), 89 /** 90 * Filter the version of the HTTP protocol used in a request. 91 * 92 * @since 2.7.0 93 * 94 * @param string $version Version of HTTP used. Accepts '1.0' and '1.1'. 95 * Default '1.0'. 96 */ 97 'httpversion' => apply_filters( 'http_request_version', '1.0' ), 98 /** 99 * Filter the user agent value sent with an HTTP request. 100 * 101 * @since 2.7.0 102 * 103 * @param string $user_agent WordPress user agent string. 104 */ 75 105 'user-agent' => apply_filters( 'http_headers_useragent', 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ), 106 /** 107 * Filter whether to pass URLs through wp_http_validate_url() in an HTTP request. 108 * 109 * @since 3.6.0 110 * 111 * @param bool $pass_url Whether to pass URLs through wp_http_validate_url(). 112 * Default false. 113 */ 76 114 'reject_unsafe_urls' => apply_filters( 'http_request_reject_unsafe_urls', false ), 77 115 'blocking' => true, … … 96 134 97 135 $r = wp_parse_args( $args, $defaults ); 136 /** 137 * Filter the arguments used in an HTTP request. 138 * 139 * @since 2.7.0 140 * 141 * @param array $r An array of HTTP request arguments. 142 * @param string $url The request URI resource. 143 */ 98 144 $r = apply_filters( 'http_request_args', $r, $url ); 99 145 … … 102 148 $r['_redirection'] = $r['redirection']; 103 149 104 // Allow plugins to short-circuit the request 150 /** 151 * Filter whether to preempt an HTTP request's return. 152 * 153 * Returning a truthy value to the filter will short-circuit 154 * the HTTP request and return early with that value. 155 * 156 * @since 2.9.0 157 * 158 * @param bool $preempt Whether to preempt an HTTP request return. Default false. 159 * @param array $r HTTP request arguments. 160 * @param string $url The request URI resource. 161 */ 105 162 $pre = apply_filters( 'pre_http_request', false, $r, $url ); 106 163 if ( false !== $pre ) … … 222 279 */ 223 280 public function _get_first_available_transport( $args, $url = null ) { 281 /** 282 * Filter which HTTP transports are available and in what order. 283 * 284 * @since 3.7.0 285 * 286 * @param array $value Array of HTTP transports to check. Default array contains 287 * 'curl', and 'streams', in that order. 288 * @param array $args HTTP request arguments. 289 * @param string $url The URL to request. 290 */ 224 291 $request_order = apply_filters( 'http_api_transports', array( 'curl', 'streams' ), $args, $url ); 225 292 … … 266 333 $response = $transports[$class]->request( $url, $args ); 267 334 335 /** 336 * Fires after an HTTP API response is received and before the response is returned. 337 * 338 * @since 2.8.0 339 * 340 * @param mixed $response HTTP Response or WP_Error object. 341 * @param string $context Context under which the hook is fired. 342 * @param string $class HTTP transport used. 343 * @param array $args HTTP request arguments. 344 * @param string $url The request URL. 345 */ 268 346 do_action( 'http_api_debug', $response, 'response', $class, $args, $url ); 269 347 … … 271 349 return $response; 272 350 351 /** 352 * Filter the HTTP API response immediately before the response is returned. 353 * 354 * @since 2.9.0 355 * 356 * @param array|obj $response HTTP Response. 357 * @param array $args HTTP request arguments. 358 * @param string $url The request URL. 359 */ 273 360 return apply_filters( 'http_response', $response, $args, $url ); 274 361 } … … 282 369 * @since 2.7.0 283 370 * 284 * @param string $urlURI resource.285 * @param str |array $args Optional. Override the defaults.371 * @param string $url URI resource. 372 * @param string|array $args Optional. Override the defaults. 286 373 * @return array|object Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error 287 374 */ … … 517 604 518 605 // Don't block requests back to ourselves by default 519 if ( $check['host'] == 'localhost' || $check['host'] == $home['host'] ) 520 return apply_filters('block_local_requests', false); 606 if ( $check['host'] == 'localhost' || $check['host'] == $home['host'] ) { 607 /** 608 * Filter whether to block local requests through the proxy. 609 * 610 * @since 2.8.0 611 * 612 * @param bool $block Whether to block local requests through proxy. 613 * Default false. 614 */ 615 return apply_filters( 'block_local_requests', false ); 616 } 521 617 522 618 if ( !defined('WP_ACCESSIBLE_HOSTS') ) … … 743 839 $is_local = isset( $r['local'] ) && $r['local']; 744 840 $ssl_verify = isset( $r['sslverify'] ) && $r['sslverify']; 745 if ( $is_local ) 841 if ( $is_local ) { 842 /** 843 * Filter whether SSL should be verified for local requests. 844 * 845 * @since 2.8.0 846 * 847 * @param bool $ssl_verify Whether to verify the SSL connection. Default true. 848 */ 746 849 $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); 747 elseif ( ! $is_local ) 850 } elseif ( ! $is_local ) { 851 /** 852 * Filter whether SSL should be verified for non-local requests. 853 * 854 * @since 2.8.0 855 * 856 * @param bool $ssl_verify Whether to verify the SSL connection. Default true. 857 */ 748 858 $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); 859 } 749 860 750 861 $proxy = new WP_HTTP_Proxy(); … … 1005 1116 1006 1117 /** 1007 * Whether this class can be used for retrieving a nURL.1118 * Whether this class can be used for retrieving a URL. 1008 1119 * 1009 1120 * @static … … 1027 1138 } 1028 1139 1140 /** 1141 * Filter whether streams can be used as a transport for retrieving a URL. 1142 * 1143 * @since 2.7.0 1144 * 1145 * @param bool $use_class Whether the class can be used. Default true. 1146 * @param array $args Request arguments. 1147 */ 1029 1148 return apply_filters( 'use_streams_transport', true, $args ); 1030 1149 } … … 1146 1265 $is_local = isset($r['local']) && $r['local']; 1147 1266 $ssl_verify = isset($r['sslverify']) && $r['sslverify']; 1148 if ( $is_local ) 1149 $ssl_verify = apply_filters('https_local_ssl_verify', $ssl_verify); 1150 elseif ( ! $is_local ) 1151 $ssl_verify = apply_filters('https_ssl_verify', $ssl_verify); 1267 if ( $is_local ) { 1268 /** This filter is documented in wp-includes/class-http.php */ 1269 $ssl_verify = apply_filters( 'https_local_ssl_verify', $ssl_verify ); 1270 } elseif ( ! $is_local ) { 1271 /** This filter is documented in wp-includes/class-http.php */ 1272 $ssl_verify = apply_filters( 'https_ssl_verify', $ssl_verify ); 1273 } 1152 1274 1153 1275 // CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT expect integers. Have to use ceil since … … 1226 1348 curl_setopt( $handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 ); 1227 1349 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. 1350 /** 1351 * Fires before the cURL request is executed. 1352 * 1353 * Cookies are not currently handled by the HTTP API. This action allows 1354 * plugins to handle cookies themselves. 1355 * 1356 * @since 2.8.0 1357 * 1358 * @param array $handle cURL options set using curl_setopt(). 1359 */ 1230 1360 do_action_ref_array( 'http_api_curl', array(&$handle) ); 1231 1361 … … 1362 1492 } 1363 1493 1494 /** 1495 * Filter whether cURL can be used as a transport for retrieving a URL. 1496 * 1497 * @since 2.7.0 1498 * 1499 * @param bool $use_class Whether the class can be used. Default true. 1500 * @param array $args An array of request arguments. 1501 */ 1364 1502 return apply_filters( 'use_curl_transport', true, $args ); 1365 1503 } … … 1530 1668 $home = parse_url( get_option('siteurl') ); 1531 1669 1670 /** 1671 * Filter whether to preempt sending the request through the proxy server. 1672 * 1673 * Returning false will bypass the proxy; returning true will send 1674 * the request through the proxy. Returning null bypasses the filter. 1675 * 1676 * @since 3.5.0 1677 * 1678 * @param null $override Whether to override the request result. Default null. 1679 * @param string $uri URL to check. 1680 * @param array $check Associative array result of parsing the URI. 1681 * @param array $home Associative array result of parsing the site URL. 1682 */ 1532 1683 $result = apply_filters( 'pre_http_send_through_proxy', null, $uri, $check, $home ); 1533 1684 if ( ! is_null( $result ) ) … … 1744 1895 return ''; 1745 1896 1897 /** 1898 * Filter the header-encoded cookie value. 1899 * 1900 * @since 3.4.0 1901 * 1902 * @param string $value The cookie value. 1903 * @param string $name The cookie name. 1904 */ 1746 1905 return $this->name . '=' . apply_filters( 'wp_http_cookie_value', $this->value, $this->name ); 1747 1906 } … … 1905 2064 } 1906 2065 2066 /** 2067 * Filter the allowed encoding types. 2068 * 2069 * @since 3.6.0 2070 * 2071 * @param array $type Encoding types allowed. Accepts 'gzinflate', 2072 * 'gzuncompress', 'gzdecode'. 2073 * @param string $url URL of the HTTP request. 2074 * @param array $args HTTP request arguments. 2075 */ 1907 2076 $type = apply_filters( 'wp_http_accept_encoding', $type, $url, $args ); 1908 2077
Note: See TracChangeset
for help on using the changeset viewer.