namedirectory: handle 404 as "notFound" for lookupAddress

Change-Id: I1c4b059e5f058c4eb929cd38875ea06beaf6ee92
This commit is contained in:
Adrien Beraud
2017-07-15 09:33:53 -04:00
parent a72465d894
commit 306aa1330a

View File

@ -115,7 +115,8 @@ void NameDirectory::lookupAddress(const std::string& addr, LookupCallback cb)
auto ret = restbed::Http::async(req, [this,cb,addr](const std::shared_ptr<restbed::Request>&,
const std::shared_ptr<restbed::Response>& reply) {
if (reply->get_status_code() == 200) {
auto code = reply->get_status_code();
if (code == 200) {
size_t length = getContentLength(*reply);
if (length > MAX_RESPONSE_SIZE) {
cb("", Response::error);
@ -142,6 +143,8 @@ void NameDirectory::lookupAddress(const std::string& addr, LookupCallback cb)
} else {
cb("", Response::notFound);
}
} else if (code >= 400 && code < 500) {
cb("", Response::notFound);
} else {
cb("", Response::error);
}