From f611990708cb199245ab2935c06f50563889d934 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 26 Nov 2018 05:11:27 +0100 Subject: [PATCH] Moved HTTP header Cache-Control and Connection to the top. This way they are alwas sent, not just on success. --- src/libravatarserv.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libravatarserv.cpp b/src/libravatarserv.cpp index 7843364..6a564fc 100644 --- a/src/libravatarserv.cpp +++ b/src/libravatarserv.cpp @@ -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"); }