+/*
+ * Main Header Filter
+ * If the current time is within office hours, it goes to the next
+ * handler. Otherwise it sets the headers to 403
+ */
+
+static ngx_int_t
+ngx_http_office_hours_header_filter(ngx_http_request_t * r)
+{
+
+ ngx_uint_t ** parsed_office_hours;
+ ngx_http_office_hours_conf_t *conf;
+
+ conf =
+ ngx_http_get_module_loc_conf(r,
+ ngx_http_office_hours_filter_module);
+
+
+ if (conf->office_hours == NULL) {
+ ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0,
+ "Office hours disabled");
+ return ngx_http_next_header_filter(r);
+ }
+
+ parsed_office_hours = parse_office_hours(conf->office_hours);
+
+ if (within_office_hours(parsed_office_hours)) {
+ ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0,
+ "Within office hours");
+ return ngx_http_next_header_filter(r);
+ }
+
+ ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0,
+ "Outside office hours");
+
+ r->headers_out.status = NGX_HTTP_FORBIDDEN;
+ r->headers_out.content_length_n = OUTPUT_HTML.len;
+
+ return ngx_http_next_header_filter(r);
+}
+