forked from tastytea/libravatarserv
Return 404 if image is not found
This commit is contained in:
parent
a094dd2896
commit
7efec890f7
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.2)
|
cmake_minimum_required (VERSION 3.2)
|
||||||
project(libravatarserv
|
project(libravatarserv
|
||||||
VERSION 0.2.3
|
VERSION 0.2.4
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,6 @@ int main()
|
||||||
cerr << "Error: Invalid URL.\n";
|
cerr << "Error: Invalid URL.\n";
|
||||||
return 1;
|
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;
|
uint16_t size = 80;
|
||||||
string digest = request.substr(8);
|
string digest = request.substr(8);
|
||||||
|
@ -75,11 +73,14 @@ int main()
|
||||||
image::Image answer = image::get(digest, size);
|
image::Image answer = image::get(digest, size);
|
||||||
if (answer.error == 0)
|
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("test.png");
|
||||||
answer.image.write("/dev/stdout");
|
answer.image.write("/dev/stdout");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
cout << "Status: 404 Not Found\n\n";
|
||||||
cerr << "Error " << std::to_string(answer.error) << ": Could not open file.\n";
|
cerr << "Error " << std::to_string(answer.error) << ": Could not open file.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user