Skip to content

Commit e264f07

Browse files
authored
Implement mod_444 to handle HTTP status 444
1 parent b8d14bb commit e264f07

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

mod_444.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#include "httpd.h"
2+
#include "http_config.h"
3+
#include "http_protocol.h"
4+
#include "http_core.h"
5+
#include "http_log.h"
6+
#include "http_request.h"
7+
#include "util_filter.h"
8+
#include "apr_buckets.h"
9+
10+
static apr_status_t mod444_out_filter(ap_filter_t *f, apr_bucket_brigade *bb)
11+
{
12+
request_rec *r = f->r;
13+
14+
if (r && r->status == 444) {
15+
if (r->connection) {
16+
r->connection->keepalive = AP_CONN_CLOSE;
17+
r->connection->aborted = 1;
18+
}
19+
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
20+
"mod_444: dropping connection on status 444");
21+
ap_remove_output_filter(f);
22+
return APR_ECONNABORTED;
23+
}
24+
25+
return ap_pass_brigade(f->next, bb);
26+
}
27+
28+
static void mod444_insert_filter(request_rec *r)
29+
{
30+
ap_add_output_filter("MOD444_OUT", NULL, r, r->connection);
31+
}
32+
33+
static void mod444_register_hooks(apr_pool_t *p)
34+
{
35+
ap_register_output_filter("MOD444_OUT", mod444_out_filter, NULL, AP_FTYPE_PROTOCOL);
36+
ap_hook_insert_filter(mod444_insert_filter, NULL, NULL, APR_HOOK_MIDDLE);
37+
}
38+
39+
module AP_MODULE_DECLARE_DATA fourfour_module =
40+
{
41+
STANDARD20_MODULE_STUFF,
42+
NULL, NULL, NULL, NULL, NULL,
43+
mod444_register_hooks
44+
};

0 commit comments

Comments
 (0)