diff options
| author | 2015-02-07 01:23:12 +0000 | |
|---|---|---|
| committer | 2015-02-07 01:23:12 +0000 | |
| commit | f8932becc4217638045512ac30c17ed5f658d036 (patch) | |
| tree | 11911a3276f17eb8e39fd0005a6aacb274328d75 /usr.sbin/httpd/server_http.c | |
| parent | New framework that allows hibernate to pass in entropy from it's fresh (diff) | |
| download | wireguard-openbsd-f8932becc4217638045512ac30c17ed5f658d036.tar.xz wireguard-openbsd-f8932becc4217638045512ac30c17ed5f658d036.zip | |
Add support for blocking, dropping, and redirecting requests.
OK florian@
Diffstat (limited to 'usr.sbin/httpd/server_http.c')
| -rw-r--r-- | usr.sbin/httpd/server_http.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 7c1fc383851..d5acb05737f 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.71 2015/02/06 13:05:20 reyk Exp $ */ +/* $OpenBSD: server_http.c,v 1.72 2015/02/07 01:23:12 reyk Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -736,6 +736,11 @@ server_abort_http(struct client *clt, u_int code, const char *msg) char tmbuf[32], hbuf[128]; int bodylen; + if (code == 0) { + server_close(clt, "dropped"); + return; + } + if ((httperr = server_httperror_byid(code)) == NULL) httperr = "Unknown Error"; @@ -957,7 +962,11 @@ server_response(struct httpd *httpd, struct client *clt) /* Now search for the location */ srv_conf = server_getlocation(clt, desc->http_path); - if (srv_conf->flags & SRVFLAG_AUTH && + if (srv_conf->flags & SRVFLAG_BLOCK) { + server_abort_http(clt, srv_conf->return_code, + srv_conf->return_uri); + return (-1); + } else if (srv_conf->flags & SRVFLAG_AUTH && server_http_authenticate(srv_conf, clt) == -1) { server_abort_http(clt, 401, srv_conf->auth_realm); return (-1); |
