1: <?php
2: 3: 4: 5: 6: 7:
8: class Horde_Controller_ResponseWriter_WebDebug implements Horde_Controller_ResponseWriter
9: {
10: public function writeResponse(Horde_Controller_Response $response)
11: {
12: $headerHtml = '<div><strong>Headers:</strong><pre>';
13: $headers = $response->getHeaders();
14: foreach ($headers as $key => $value) {
15: $headerHtml .= htmlspecialchars("$key: $value\n");
16: }
17: echo $headerHtml . '</pre></div>';
18:
19: if (isset($headers['Location'])) {
20: echo '<p>Redirect To: <a href="' . htmlspecialchars($headers['Location']) . '">' . htmlspecialchars($headers['Location']) . '</a></p>';
21: }
22:
23: $body = $response->getBody();
24: if (is_resource($body)) {
25: $body = stream_get_contents($body);
26: }
27: if (isset($headers['Content-Encoding']) && $headers['Content-Encoding'] == 'gzip') {
28:
29: echo gzinflate(substr($body, 10));
30: } else {
31: echo $body;
32: }
33: }
34: }
35: