Return 404 if image is not found

This commit is contained in:
tastytea 2018-11-25 08:35:43 +01:00
parent a094dd2896
commit 7efec890f7
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 4 additions and 3 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.2)
project(libravatarserv
VERSION 0.2.3
VERSION 0.2.4
LANGUAGES CXX
)

View File

@ -55,8 +55,6 @@ int main()
cerr << "Error: Invalid URL.\n";
return 1;
}
cout << "Content-type: image/png\n\n";
cout.flush(); // We need to flush before we use /dev/stdout directly.
uint16_t size = 80;
string digest = request.substr(8);
@ -75,11 +73,14 @@ int main()
image::Image answer = image::get(digest, size);
if (answer.error == 0)
{
cout << "Content-type: image/png\n\n";
cout.flush(); // We need to flush before we use /dev/stdout directly.
// answer.image.write("test.png");
answer.image.write("/dev/stdout");
}
else
{
cout << "Status: 404 Not Found\n\n";
cerr << "Error " << std::to_string(answer.error) << ": Could not open file.\n";
}