Changed the HTTP Status responses to be more accurate
the build was successful Details

This commit is contained in:
tastytea 2018-11-28 10:31:20 +01:00
parent 1dad647059
commit 3e037d4936
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 6 additions and 7 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.2)
project(libravatarserv
VERSION 0.6.0
VERSION 0.6.1
LANGUAGES CXX
)

View File

@ -29,7 +29,7 @@ const Request http::parse_request(const string &request)
if (request.substr(0, 8) != "/avatar/" ||
request.find("..", 8) != std::string::npos)
{
cout << "Status: 404 Not Found\n\n";
cout << "Status: 400 Bad Request\n\n";
cerr << "Error: Invalid URL.\n";
std::exit(0);
}

View File

@ -40,14 +40,14 @@ int main()
const char *request = std::getenv("REQUEST_URI");
if (request == nullptr)
{
cout << "Status: 404 Not Found\n\n";
cout << "Status: 400 Bad Request\n\n";
cerr << "Error: ${REQUEST_URI} is empty.\n";
return 1;
}
if (!find_avatar_dir())
{
cout << "Status: 404 Not Found\n\n";
cout << "Status: 503 Service Unavailable\n\n";
cerr << "Error: No avatars found.\n";
return 3;
}
@ -108,7 +108,7 @@ int main()
}
else
{
cout << "Status: 404 Not Found\n\n";
cout << "Status: 500 Internal Server Error\n\n";
cerr << "Error: Couldn't generate identicon.\n";
}
}
@ -117,11 +117,10 @@ int main()
if (global::settings.redirect_nofallback)
{
http::send_redirect(avatar);
return 0;
}
else
{
cout << "Status: 404 Not Found\n\n";
cout << "Status: 501 Not Implemented\n\n";
}
}
}