1<?php
2
3/**
4 * This simple example shows the capability of Request and Response objects to
5 * serialize themselves as strings.
6 *
7 * This is mainly useful for debugging purposes.
8 *
9 * @copyright Copyright (C) 2009-2015 fruux GmbH (https://fruux.com/).
10 * @author Evert Pot (http://evertpot.com/)
11 * @license http://sabre.io/license/ Modified BSD License
12 */
13use Sabre\HTTP\Request;
14use Sabre\HTTP\Response;
15
16// Find the autoloader
17$paths = [
18    __DIR__ . '/../vendor/autoload.php',
19    __DIR__ . '/../../../autoload.php',
20    __DIR__ . '/vendor/autoload.php',
21
22];
23foreach ($paths as $path) {
24    if (file_exists($path)) {
25        include $path;
26        break;
27    }
28}
29
30$request = new Request('POST', '/foo');
31$request->setHeaders([
32    'Host'         => 'example.org',
33    'Content-Type' => 'application/json'
34    ]);
35
36$request->setBody(json_encode(['foo' => 'bar']));
37
38echo $request;
39echo "\r\n\r\n";
40
41$response = new Response(424);
42$response->setHeaders([
43    'Content-Type' => 'text/plain',
44    'Connection'   => 'close',
45    ]);
46
47$response->setBody("ABORT! ABORT!");
48
49echo $response;
50
51echo "\r\n";
52