WP_CLI\Utils\http_request() Edit

Make a HTTPHTTP HTTP is an acronym for Hyper Text Transfer Protocol. HTTP is the underlying protocol used by the World Wide Web and this protocol defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands. request to a remote URLURL A specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org.


WP_CLI\Utils\http_request( $method, $url, $data = null, $headers = [], $options = [] )
$method (string) HTTP method (GET, POST, DELETE, etc.).
$url (string) URL to make the HTTP request to.
$data (array|null) Data to send either as a query string for GET/HEAD requests,
$headers (array) Add specific headers to the request.
$options (array) {
Optional. An associative array of additional request options.
@type bool $halt_on_error Whether or not command execution should be halted on error. Default: true
@type bool|string $verify A boolean to use enable/disable SSLSSL Secure Socket Layer - Encryption from the server to the browser and back. Prevents prying eyes from seeing what you are sending between your browser and the server. verification
or string absolute path to CA cert to use.
Defaults to detected CA cert bundled with the Requests library.
@type bool $insecure Whether to retry automatically without certificate validation.
@return (object)

Top ↑


Wraps the Requests HTTP library to ensure every request includes a cert.

# `wp core download` verifies the hash for a downloaded WordPress archive

$md5_response = Utils\http_request( 'GET', $download_url . '.md5' );
if ( 20 != substr( $md5_response->status_code, 0, 2 ) ) {
     WP_CLI::error( "Couldn't access md5 hash for release (HTTP code {$response->status_code})" );
                       or in the body for POST requests.

Internal APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. documentation is generated from the WP-CLIWP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/ https://make.wordpress.org/cli/ codebase on every release. To suggest improvements, please submit a pull request.

Top ↑

  • WP_CLI\Utils\write_csv() – Write data as CSV to a given file.
  • WP_CLI\Utils\get_named_sem_ver() – Compare two version strings to get the named semantic version.
  • WP_CLI\Utils\parse_ssh_url() – Parse a SSHSSH Secure SHell - a protocol for securely connecting to a remote system in addition to or in place of a password. url for its host, port, and path.
  • WP_CLI\Utils\basename() – Locale-independent version of basename()
  • WP_CLI\Utils\isPiped() – Checks whether the output of the current script is a TTY or a pipe / redirect
  • WP_CLI\Utils\proc_open_compat() – Windows compatible `proc_open()`. Works around bug in PHPPHP PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. http://php.net/manual/en/intro-whatis.php., and also deals with *nix-like `ENV_VAR=blah cmd` environment variable prefixes.
  • WP_CLI\Utils\esc_like() – First half of escaping for LIKE special characters % and _ before preparing for MySQLMySQL MySQL is a relational database management system. A database is a structured collection of data where content, configuration and other options are stored. https://www.mysql.com/..

Last updated: