{"action":"opened","issue":{"url":"https://api.github.com/repos/slimphp/Slim/issues/1503","labels_url":"https://api.github.com/repos/slimphp/Slim/issues/1503/labels{/name}","comments_url":"https://api.github.com/repos/slimphp/Slim/issues/1503/comments","events_url":"https://api.github.com/repos/slimphp/Slim/issues/1503/events","html_url":"https://github.com/slimphp/Slim/issues/1503","id":107379944,"number":1503,"title":"Slim 3 Bug - can't set the content type in separate files?","user":{"login":"lauthiamkok","id":427931,"avatar_url":"https://avatars.githubusercontent.com/u/427931?v=3","gravatar_id":"","url":"https://api.github.com/users/lauthiamkok","html_url":"https://github.com/lauthiamkok","followers_url":"https://api.github.com/users/lauthiamkok/followers","following_url":"https://api.github.com/users/lauthiamkok/following{/other_user}","gists_url":"https://api.github.com/users/lauthiamkok/gists{/gist_id}","starred_url":"https://api.github.com/users/lauthiamkok/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lauthiamkok/subscriptions","organizations_url":"https://api.github.com/users/lauthiamkok/orgs","repos_url":"https://api.github.com/users/lauthiamkok/repos","events_url":"https://api.github.com/users/lauthiamkok/events{/privacy}","received_events_url":"https://api.github.com/users/lauthiamkok/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-20T08:33:52Z","updated_at":"2015-09-20T08:33:52Z","closed_at":null,"body":"I think there is a bug in Slim 3.\r\n\r\n```\r\n    require_once __DIR__ . '/../vendor/autoload.php';\r\n    \r\n    $app = new \\Slim\\App();\r\n    \r\n    // Routes:\r\n    $app->get('/hello/{name}', function ($request, $response, $args) {\r\n\r\n        // fetch the id attribute to discover what was matched.\r\n        $name = $request->getAttribute('name');\r\n    \r\n        $response->getBody()->write('Hello, ' . $name);\r\n        return $response->withHeader('Content-type', 'application/json');\r\n    \r\n    });\r\n    \r\n    $app->run();\r\n```\r\n\r\nTest\r\nhttp://example.com/public/hello/world\r\n\r\n``` \r\n   Connection Keep-Alive\r\n    Content-Length 12\r\n    Content-Type application/json\r\n    Date Sun, 20 Sep 2015 06:53:57 GMT\r\n    Keep-Alive\ttimeout=5, max=100\r\n    Server Apache/2.4.7 (Win32) PHP/5.5.8\r\n    X-Powered-By PHP/5.5.8\r\n```\r\n\r\nI get `Content-Type` as `application/json` as I want which is correct.\r\n\r\nBut if I try **separate** the code and use require_once or include to fetch the file, the `Content-Type` becomes `text/html`!\r\n\r\n```\r\n    $app->get('/hello/{name}', function ($request, $response, $args) {\r\n    \r\n        // fetch the id attribute to discover what was matched.\r\n        $name = $request->getAttribute('name');\r\n    \r\n        require_once __DIR__ . '/hello.php';\r\n    \r\n    });\r\n    \r\n    $app->run();\r\n```\r\n\r\nhello.php,\r\n\r\n```\r\n    $response->getBody()->write('Hello, ' . $name);\r\n    return $response->withHeader('Content-type', 'application/json');\r\n```\r\n\r\nTest\r\nhttp://example.com/public/hello/world\r\n\r\n```\r\n    Connection Keep-Alive\r\n    Content-Length 12\r\n    Content-Type text/html\r\n    Date Sun, 20 Sep 2015 06:53:57 GMT\r\n    Keep-Alive\ttimeout=5, max=100\r\n    Server Apache/2.4.7 (Win32) PHP/5.5.8\r\n    X-Powered-By PHP/5.5.8\r\n```\r\nIt seems can't set the content type in the separate file which does not really make sense...\r\n\r\nWhy?? Any ideas?"}}