I am trying to return 204 HTTP
code on users /logout
request. As I have discovered this code signals that server has processed request successfully, but no response required.
I am checking this response on mobile device, not exactly I but OkHTTP library in my case.
And it throws an exception if Content-Length
is not 0. I have tried to send it via chrome extension and get following response
Response does not contain any data.
So seems to be no response but Content-Length:5.
So I am very confused about this, I have captured packets via WireShark and here is result
\n\n\n\t\n
Here is my simple code for handling request
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->add(new \TokenAuth());
$app->put('/test204', function () use ($app) {
$app->response->setStatus(204);
});
All seems to by fine, I have no idea where this garbage is set.
Please help to solve the problem,because I cannot receive valid response on client app and just ignoring exception is not solution for this problem.
Sorry the problem was not with Slim Framework. I am newbie and didn't know that even special characters comming after ?>
will go to the output as plain html text.
I have to delete all spaces, tabs and other characters after the end of php scripts.
To find files that ends with new line use following bash command.
find -type f -exec sh -c '[ -z "$(sed -n "\$p" "$1")" ] && ec
ho "$1"' _ {} \;
I wonder maybe there any way to make apache to skip empty characters, new lines and other garbage at the on of file.