Hooking system

Requests has a hook system that you can use to manipulate parts of the request process along with internal transport hooks.

Check out the API documentation for WpOrg\Requests\Hooks for more information on how to use the hook system.

Available Hooks

This optional parameter will be present when a blocking request was made ($options['blocking' = true) and will not be present when a non-blocking request was made ($options['blocking' = false). The callback signature needs to be adapted accordingly.

This optional parameter will be present when a blocking request was made ($options['blocking' = true) and will not be present when a non-blocking request was made ($options['blocking' = false). The callback signature needs to be adapted accordingly.

Registering Hooks

Note: if you’re doing this in an authentication handler, see the Custom Authentication guide instead.

In order to register your own hooks, you need to instantiate WpOrg\Requests\Hooks and pass the object in via the 'hooks' option.

$hooks = new \WpOrg\Requests\Hooks();
$hooks->register('requests.after_request', 'mycallback');

$request = \WpOrg\Requests\Requests::get('https://httpbin.org/get', array(), array('hooks' => $hooks));

Previous: Requests through proxy

Next: Upgrading to Requests 2.0


Is something missing in this documentation or did you find something to be wrong?
Please create an issue to help us improve the documentation.