If you take a look at WP_HTTP->request()
(which all related functions wrap) it provides a filter hook for the purpose of overriding making a request in favor of returning arbitrary data as response:
// Allow plugins to short-circuit the request
$pre = apply_filters( 'pre_http_request', false, $r, $url );
if ( false !== $pre )
return $pre;
Related Posts:
- How to control accept encoding on HTTP API requests?
- Mutual Authentiction on HTTPS with WordPress HTTP API?
- How to use WordPress HTTP API to download file from remote location
- HTTP digest authentication using wp_remote_get
- Error timed out with succesfull wp_remote_post
- Difference between wp_remote_post and wp_safe_remote_post
- How to consume and display external data in WordPress from another website
- cURL vs WP_Http for safety?
- Posting an XML request using HTTP API
- Is it possible to process $_POST / inbound http request in way to automatically create WordPress post?
- What’s the best way to detect referrer?
- Behind-the-scenes HTTP Request?
- Sending JSON Payload using Request::request_multiple()
- wp remote post getting a 404 error code
- wp_remote_request header error even though working properly with cURL
- Proper context for wp_remote_post()
- How to add code to HTTP header
- Using WP_Http to post data to Webservice without blocking caller script
- wp_http remote request not respecting timeout
- Testing hooks callback
- Where can I find documentation for the WP_UnitTestCase factory classes?
- Sending JSON string through wp_remote_post()
- Filter any HTTP request URI?
- Unit testing in the WordPress backend (is_admin() is true)
- How to remove rest api link: in http headers?
- Access post from post id in URL
- Proper unit testing in WordPress
- WordPress Themes and PHP unit
- How to use the HTTP API with a Proxy?
- Unit tests – Dealing with dependencies
- When unit testing a plugin, does the plugin need to be in the wp-content/plugins directory of the WordPress tests install?
- How to set up a user inside unit tests
- Writing test cases for a WordPress Plugin that has translations
- WordPress test environment on windows
- WordPress Unit Testing – Cannot Create Tables
- Can I simulate a user being logged in from a WP_UnitTestCase?
- Plugin Unit Test for Table and Option Creation
- How to write testable classes in WordPress
- Hook into WordPress update?
- PHPUnit testing WordPress Plugin
- Writing a unit test for add_menu_page
- How to create a test that calls is_front_page in phpunit?
- Can’t get the phpunit core test for WordPress to work [closed]
- Using wp_mail during an integration test
- Implement phpunit testing on a plugin
- How to run multiple Async HTTP requests in WordPress?
- What areas to Unit test while building a plugin?
- Why Can’t PHPUnit UnitTest My WordPress Website
- Unit testing to simulate the loop
- how to test a theme upgrade
- struggling to set up WP tests
- WP_UnitTestCase missing?
- WP_Http_Cookie destroys cookie value through urldecode()
- What is the best way to do unit tests for your plugin in 2018 [closed]
- Is there any way of of making an admin-ajax request without the use of die()?
- Using Travis CI to run unit tests and running phpunit locally [closed]
- Revert WordPress default options after a PHPUnit test has run
- Plugin development with unit tests
- parse XML from URL (via SOAP)
- POST to a REST API from a wordpress form
- Unit testing wordpress plugins with plugin options
- How can I properly set up dependencies in automated testing?
- How to properly test a method that is called by an action hook
- Install and load additional plugins when running unit tests
- Unit Testing a Plugin functionality with cron
- Connect external web app to wordpress
- PHPUnit test plugin activation
- Installing WordPress Theme Unit Data
- How to add an image for unit testing?
- Fatal error: Maximum execution time of 60 seconds exceeded in H:\wamp\www\custom\wp-includes\class-wp-http-curl.php
- API JSON Data in WordPress
- How do I mock get_adjacent_post for testing
- Storing an XML Response (Transient)?
- Why is WP_Mock not used instead of WP_UnitTestCase for writing unit tests by most plugins?
- How do I get URL from WP_HTTP object?
- DataBase connection problem with PHPUnit and WordPress
- What is the official way to consume the WordPress API? (api.wordpress.org)
- Allow download_url for lan addresses
- How to duplicate a curl XML request using HTTP API?
- Using factory.php outside of trunk for unit testing
- WordPress function gives different results outside vs inside PHPUnit test
- how to set context in WordPress for unit testing
- How to set charset for wp_remote_post request?
- Setting Up PHPUnit tests for WP development on Windows
- unit testing admin password
- wp_remote_post with ssl:// protocol
- Testing custom API endpoint with class dependency
- How to verify meta box is registered in Unit Testing?
- Extending WordPress REST API
- Theme unit test data Foreign fonts come in garbled on my machine
- Inconsistent server code response using HTTP API
- using wp_remote_get to retrieve own url on local host
- Does WordPress’s HTTP API use any caching?
- How to convert this cURL to wp_remote_get?
- How exactly *does* unit testing work for themes?
- How to initialize something in unit test before the init hook being called?
- How deactivate the http-api
- Unit Test in WordPress
- What is the best way to create a factory for unit test objects?
- How to make Http Request to a php file present in plugin directory of wordpress