Browse Source

remove unused con->error_handler member

Also remove con->in_error_handler member since non-zero
con->error_handler_saved_status can be used as flag to
indicate the same thing
personal/stbuehler/mod-csrf-old
Glenn Strauss 6 years ago
parent
commit
87b172e70e
  1. 2
      src/base.h
  2. 34
      src/connections.c

2
src/base.h

@ -446,9 +446,7 @@ typedef struct {
buffer *server_name;
/* error-handler */
buffer *error_handler;
int error_handler_saved_status;
int in_error_handler;
struct server_socket *srv_socket; /* reference to the server-socket */

34
src/connections.c

@ -445,7 +445,6 @@ connection *connection_init(server *srv) {
CLEAN(parse_request);
CLEAN(server_name);
CLEAN(error_handler);
CLEAN(dst_addr_buf);
#if defined USE_OPENSSL && ! defined OPENSSL_NO_TLSEXT
CLEAN(tlsext_server_name);
@ -516,7 +515,6 @@ void connections_free(server *srv) {
CLEAN(parse_request);
CLEAN(server_name);
CLEAN(error_handler);
CLEAN(dst_addr_buf);
#if defined USE_OPENSSL && ! defined OPENSSL_NO_TLSEXT
CLEAN(tlsext_server_name);
@ -589,7 +587,6 @@ int connection_reset(server *srv, connection *con) {
CLEAN(parse_request);
CLEAN(server_name);
CLEAN(error_handler);
#if defined USE_OPENSSL && ! defined OPENSSL_NO_TLSEXT
CLEAN(tlsext_server_name);
#endif
@ -634,7 +631,6 @@ int connection_reset(server *srv, connection *con) {
/* config_cond_cache_reset(srv, con); */
con->header_len = 0;
con->in_error_handler = 0;
con->error_handler_saved_status = 0;
config_setup_connection(srv, con);
@ -1026,13 +1022,18 @@ int connection_state_machine(server *srv, connection *con) {
switch (r = http_response_prepare(srv, con)) {
case HANDLER_FINISHED:
if (con->mode == DIRECT) {
if (con->http_status == 404 ||
con->http_status == 403) {
if (con->error_handler_saved_status) {
if (con->http_status == 404 || con->http_status == 403) {
/* error-handler-404 is a 404 */
con->http_status = con->error_handler_saved_status;
} else {
/* error-handler-404 is back and has generated content */
/* if Status: was set, take it otherwise use 200 */
}
} else if (con->http_status == 404 || con->http_status == 403) {
/* 404 error-handler */
if (con->in_error_handler == 0 &&
(!buffer_string_is_empty(con->conf.error_handler) ||
!buffer_string_is_empty(con->error_handler))) {
if (!buffer_string_is_empty(con->conf.error_handler)) {
/* call error-handler */
/* set REDIRECT_STATUS to save current HTTP status code
@ -1049,26 +1050,13 @@ int connection_state_machine(server *srv, connection *con) {
con->error_handler_saved_status = con->http_status;
con->http_status = 0;
if (buffer_string_is_empty(con->error_handler)) {
buffer_copy_buffer(con->request.uri, con->conf.error_handler);
} else {
buffer_copy_buffer(con->request.uri, con->error_handler);
}
buffer_copy_buffer(con->request.uri, con->conf.error_handler);
buffer_reset(con->physical.path);
connection_handle_errdoc_init(con);
con->in_error_handler = 1;
done = -1;
break;
} else if (con->in_error_handler) {
/* error-handler is a 404 */
con->http_status = con->error_handler_saved_status;
}
} else if (con->in_error_handler) {
/* error-handler is back and has generated content */
/* if Status: was set, take it otherwise use 200 */
}
}
if (con->http_status == 0) con->http_status = 200;

Loading…
Cancel
Save