diff options
author | nntrab <kolmar@hotmail.co.uk> | 2016-02-09 18:01:00 +0000 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2020-01-13 00:50:14 +0300 |
commit | 02905413fdb290c75f67644f270150d60fe50805 (patch) | |
tree | 357cb26724cfe9e1b97062d08c06f4af954acd36 /sample | |
parent | 462f2e97660cc2b6af563ab631050a83c3e0935b (diff) | |
download | libevent-02905413fdb290c75f67644f270150d60fe50805.tar.gz |
Add callback support for error pages
The existing error pages are very basic and don't allow for
multi-lingual support or for conformity with other pages in a web site.
The aim of the callback functionality is to allow custom error pages to
be supported for calls to evhttp_send_error() by both calling
applications and Libevent itself.
A backward-incompatible change has been made to the title of error pages
sent by evhttp_send_error(). The original version of the function used
the reason argument as part of the title. That might have unforeseen
side-effects if it contains HTML tags. Therefore the title has been
changed to always use the standard status text.
An example of the error callback can be found in this
[version](https://github.com/libevent/libevent/files/123607/http-server.zip)
of the 'http-server' sample. It will output error pages with very bright
backgrounds, the error code using a very large font size and the reason.
Closes: #323 (cherr-picked from PR)
Diffstat (limited to 'sample')
-rw-r--r-- | sample/http-server.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sample/http-server.c b/sample/http-server.c index 049aabc4..09d829c6 100644 --- a/sample/http-server.c +++ b/sample/http-server.c @@ -329,7 +329,7 @@ send_document_cb(struct evhttp_request *req, void *arg) evhttp_send_reply(req, 200, "OK", evb); goto done; err: - evhttp_send_error(req, 404, "Document was not found"); + evhttp_send_error(req, HTTP_NOTFOUND, NULL); if (fd>=0) close(fd); done: |