aboutsummaryrefslogtreecommitdiff
path: root/server_http.c
diff options
context:
space:
mode:
Diffstat (limited to 'server_http.c')
-rw-r--r--server_http.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/server_http.c b/server_http.c
index 0113a82..f7990b0 100644
--- a/server_http.c
+++ b/server_http.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server_http.c,v 1.69 2015/01/21 22:21:05 reyk Exp $ */
+/* $OpenBSD: server_http.c,v 1.70 2015/02/05 10:47:53 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);
@@ -1199,16 +1208,17 @@ server_httpmethod_cmp(const void *a, const void *b)
const char *
server_httperror_byid(u_int id)
{
- struct http_error error, *res = NULL;
+ struct http_error error, *res;
/* Set up key */
error.error_code = (int)id;
- res = bsearch(&error, http_errors,
+ if ((res = bsearch(&error, http_errors,
sizeof(http_errors) / sizeof(http_errors[0]) - 1,
- sizeof(http_errors[0]), server_httperror_cmp);
+ sizeof(http_errors[0]), server_httperror_cmp)) != NULL)
+ return (res->error_name);
- return (res->error_name);
+ return (NULL);
}
static int