WP_Http
- Since
- 2.7.0
- Source
wp-includes/class-wp-http.php:28
Core class used for managing HTTP transports and making HTTP requests.
Description
This class is used to consistently make outgoing HTTP requests easy for developers while still being compatible with the many PHP configurations under which WordPress runs.
Debugging includes several actions, which pass different variables for debugging the HTTP API.
Compatibility
- WordPress
- since 2.7.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 17
Every hook that fires from inside WP_Http, in the order it appears in the class, grouped by the method that fires it.
WP_Http::request()
- apply_filters( http_request_timeout )filter line 176
- apply_filters( http_request_redirection_count )filter line 186
- apply_filters( http_request_version )filter line 196
- apply_filters( http_headers_useragent )filter line 206
- apply_filters( http_request_reject_unsafe_urls )filter line 216
- apply_filters( http_request_args )filter line 247
- apply_filters( pre_http_request )filter line 272
- do_action( http_api_debug )action line 292
- do_action( http_api_debug )action line 299
- do_action( http_api_debug )action line 316
- apply_filters( https_ssl_verify )filter line 392
- do_action( http_api_debug )action line 435
- apply_filters( http_response )filter line 462
WP_Http::_get_first_available_transport()
- do_action( http_api_transports )filter_deprecated line 555
WP_Http::_dispatch_request()
- do_action( http_api_debug )action line 608
- apply_filters( http_response )filter line 615
Methods · 18
- request()Send an HTTP request to a URI.
- normalize_cookies()Normalizes cookies for using in Requests.
- browser_redirect_compatibility()Match redirect behavior to browser handling.
- validate_redirects()Validate redirected URLs.
- _get_first_available_transport()Tests which transports are capable of supporting the request.
- _dispatch_request()Dispatches a HTTP request to a supporting transport.
- post()Uses the POST HTTP method.
- get()Uses the GET HTTP method.
- head()Uses the HEAD HTTP method.
- processResponse()Parses the responses and splits the parts into headers and body.
- processHeaders()Transforms header string into an array.
- buildCookieHeader()Takes the arguments for a ::request() and checks for the cookie array.
- chunkTransferDecode()Decodes chunk transfer-encoding, based off the HTTP 1.1 specification.
- block_request()Determines whether an HTTP API request to the given URL should be blocked.
- parse_url()Used as a wrapper for PHP's parse_url() function that handles edgecases in < PHP 5.4.7.
- make_absolute_url()Converts a relative URL to an absolute URL relative to a given URL.
- handle_redirects()Handles an HTTP redirect and follows it if appropriate.
- is_ip_address()Determines if a specified string represents an IP address or not.
Source code
#[AllowDynamicProperties]class WP_Http { // Aliases for HTTP response codes. const HTTP_CONTINUE = 100; const SWITCHING_PROTOCOLS = 101; const PROCESSING = 102; const EARLY_HINTS = 103; const OK = 200; const CREATED = 201; const ACCEPTED = 202; const NON_AUTHORITATIVE_INFORMATION = 203; const NO_CONTENT = 204; const RESET_CONTENT = 205; const PARTIAL_CONTENT = 206; const MULTI_STATUS = 207; const IM_USED = 226; const MULTIPLE_CHOICES = 300; const MOVED_PERMANENTLY = 301; const FOUND = 302; const SEE_OTHER = 303; const NOT_MODIFIED = 304; const USE_PROXY = 305; const RESERVED = 306; const TEMPORARY_REDIRECT = 307; const PERMANENT_REDIRECT = 308; const BAD_REQUEST = 400; const UNAUTHORIZED = 401; const PAYMENT_REQUIRED = 402; const FORBIDDEN = 403; const NOT_FOUND = 404; const METHOD_NOT_ALLOWED = 405; const NOT_ACCEPTABLE = 406; const PROXY_AUTHENTICATION_REQUIRED = 407; const REQUEST_TIMEOUT = 408; const CONFLICT = 409; const GONE = 410; const LENGTH_REQUIRED = 411; const PRECONDITION_FAILED = 412; const REQUEST_ENTITY_TOO_LARGE = 413; const REQUEST_URI_TOO_LONG = 414; const UNSUPPORTED_MEDIA_TYPE = 415; const REQUESTED_RANGE_NOT_SATISFIABLE = 416; const EXPECTATION_FAILED = 417; const IM_A_TEAPOT = 418; const MISDIRECTED_REQUEST = 421; const UNPROCESSABLE_ENTITY = 422; const LOCKED = 423; const FAILED_DEPENDENCY = 424; const TOO_EARLY = 425; const UPGRADE_REQUIRED = 426; const PRECONDITION_REQUIRED = 428; const TOO_MANY_REQUESTS = 429; const REQUEST_HEADER_FIELDS_TOO_LARGE = 431; const UNAVAILABLE_FOR_LEGAL_REASONS = 451; const INTERNAL_SERVER_ERROR = 500; const NOT_IMPLEMENTED = 501; const BAD_GATEWAY = 502; const SERVICE_UNAVAILABLE = 503; const GATEWAY_TIMEOUT = 504; const HTTP_VERSION_NOT_SUPPORTED = 505; const VARIANT_ALSO_NEGOTIATES = 506; const INSUFFICIENT_STORAGE = 507; const NOT_EXTENDED = 510; const NETWORK_AUTHENTICATION_REQUIRED = 511; /** * Send an HTTP request to a URI. * * Please note: The only URI that are supported in the HTTP Transport implementation * are the HTTP and HTTPS protocols. * * @since 2.7.0 * * @param string $url The request URL. * @param string|array $args {Changelog
Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/class-wp-http.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.