Moved HTTP header Cache-Control and Connection to the top.

This way they are alwas sent, not just on success.
This commit is contained in:
tastytea 2018-11-26 05:11:27 +01:00
parent 4da9a2144e
commit f611990708
Signed by untrusted user: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 4 additions and 3 deletions

View File

@ -33,6 +33,9 @@ fs::path global::avatar_dir = "";
int main()
{
cout << "Server: libravatarserv/" << global::version << endl;
cout << "Cache-Control: max-age=86400\n";
cout << "Connection: close\n";
const char *request = std::getenv("REQUEST_URI");
if (request == nullptr)
{
@ -54,9 +57,7 @@ int main()
image::Image answer = image::get(avatar.digest, avatar.size);
if (answer.error == 0)
{
cout << "Content-type: image/png\n";
cout << "Cache-Control: max-age=86400\n";
cout << "Connection: close\n\n";
cout << "Content-type: image/png\n\n";
cout.flush(); // We need to flush before we use /dev/stdout directly.
answer.image.write("/dev/stdout");
}