Skip to content

Commit

Permalink
Implement configurable custom error pages (PR#848).
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksostapenko committed Oct 25, 2017
1 parent 9056461 commit aceb4ad
Show file tree
Hide file tree
Showing 5 changed files with 516 additions and 241 deletions.
15 changes: 8 additions & 7 deletions tempesta_fw/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,8 @@ tfw_handle_validation_req(TfwHttpReq *req, TfwCacheEntry *ce)
|| (req->method == TFW_HTTP_METH_HEAD))
__send_304(req, ce);
else
tfw_http_send_412(req);
HTTP_SEND_RESP(req, 412, "request validatin:"
" precondition failed");

return false;
}
Expand Down Expand Up @@ -1397,14 +1398,14 @@ tfw_cache_purge_method(TfwHttpReq *req)

/* Deny PURGE requests by default. */
if (!(cache_cfg.cache && vhost->cache_purge && vhost->cache_purge_acl)) {
tfw_http_send_403(req, "purge: not configured");
HTTP_SEND_RESP(req, 403, "purge: not configured");
return;
}

/* Accept requests from configured hosts only. */
ss_getpeername(req->conn->sk, &saddr);
if (!tfw_capuacl_match(vhost, &saddr)) {
tfw_http_send_403(req, "purge: ACL violation");
HTTP_SEND_RESP(req, 403, "purge: ACL violation");
return;
}

Expand All @@ -1414,14 +1415,14 @@ tfw_cache_purge_method(TfwHttpReq *req)
ret = tfw_cache_purge_invalidate(req);
break;
default:
tfw_http_send_403(req, "purge: invalid option");
HTTP_SEND_RESP(req, 403, "purge: invalid option");
return;
}

if (ret)
tfw_http_send_404(req, "purge: processing error");
HTTP_SEND_RESP(req, 404, "purge: processing error");
else
tfw_http_send_200(req);
HTTP_SEND_RESP(req, 200, "purge: success");
}

/**
Expand Down Expand Up @@ -1606,7 +1607,7 @@ cache_req_process_node(TfwHttpReq *req, tfw_http_cache_cb_t action)
resp->flags |= TFW_HTTP_RESP_STALE;
out:
if (!resp && (req->cache_ctl.flags & TFW_HTTP_CC_OIFCACHED))
tfw_http_send_504(req, "resource not cached");
HTTP_SEND_RESP(req, 504, "resource not cached");
else
/*
* TODO: RFC 7234 4.3.2: Extend preconditional request headers
Expand Down
Loading

0 comments on commit aceb4ad

Please sign in to comment.