client.php 836 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * This example shows how to make a HTTP request with the Request and Response
  4. * objects.
  5. *
  6. * @copyright Copyright (C) 2009-2015 fruux GmbH (https://fruux.com/).
  7. * @author Evert Pot (http://evertpot.com/)
  8. * @license http://sabre.io/license/ Modified BSD License
  9. */
  10. use Sabre\HTTP\Client;
  11. use Sabre\HTTP\Request;
  12. // Find the autoloader
  13. $paths = [
  14. __DIR__.'/../vendor/autoload.php',
  15. __DIR__.'/../../../autoload.php',
  16. __DIR__.'/vendor/autoload.php',
  17. ];
  18. foreach ($paths as $path) {
  19. if (file_exists($path)) {
  20. include $path;
  21. break;
  22. }
  23. }
  24. // Constructing the request.
  25. $request = new Request('GET', 'http://localhost/');
  26. $client = new Client();
  27. // $client->addCurlSetting(CURLOPT_PROXY,'localhost:8888');
  28. $response = $client->send($request);
  29. echo "Response:\n";
  30. echo (string) $response;