Transport.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * Base HTTP transport
  4. *
  5. * @package Requests\Transport
  6. */
  7. namespace WpOrg\Requests;
  8. /**
  9. * Base HTTP transport
  10. *
  11. * @package Requests\Transport
  12. */
  13. interface Transport {
  14. /**
  15. * Perform a request
  16. *
  17. * @param string $url URL to request
  18. * @param array $headers Associative array of request headers
  19. * @param string|array $data Data to send either as the POST body, or as parameters in the URL for a GET/HEAD
  20. * @param array $options Request options, see {@see \WpOrg\Requests\Requests::response()} for documentation
  21. * @return string Raw HTTP result
  22. */
  23. public function request($url, $headers = [], $data = [], $options = []);
  24. /**
  25. * Send multiple requests simultaneously
  26. *
  27. * @param array $requests Request data (array of 'url', 'headers', 'data', 'options') as per {@see \WpOrg\Requests\Transport::request()}
  28. * @param array $options Global options, see {@see \WpOrg\Requests\Requests::response()} for documentation
  29. * @return array Array of \WpOrg\Requests\Response objects (may contain \WpOrg\Requests\Exception or string responses as well)
  30. */
  31. public function request_multiple($requests, $options);
  32. /**
  33. * Self-test whether the transport can be used.
  34. *
  35. * The available capabilities to test for can be found in {@see \WpOrg\Requests\Capability}.
  36. *
  37. * @param array<string, bool> $capabilities Optional. Associative array of capabilities to test against, i.e. `['<capability>' => true]`.
  38. * @return bool Whether the transport can be used.
  39. */
  40. public static function test($capabilities = []);
  41. }