Created
October 18, 2014 02:29
-
-
Save jm42/c0ab0ca6c5c0912ffed4 to your computer and use it in GitHub Desktop.
Response send
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function send(Response $response) { | |
| if (headers_sent()) { | |
| return; | |
| } | |
| http_response_code($response->status); | |
| foreach ($response->headers as $key => $value) { | |
| if (is_array($value)) { | |
| foreach ($value as $content) { | |
| header($key . ': ' . $content, false); | |
| } | |
| continue; | |
| } | |
| header($key . ': ' . $value); | |
| } | |
| if ($response->body !== null) { | |
| file_put_contents('php://output', $response->body); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment