annotate ngx_http_compose_filter_module.c @ 0:6535d94ae07d

Compose filter module skeleton, currently does nothing.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 12 Jul 2008 19:23:17 +0400
parents
children ba5471a3c988
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
1
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
2 /*
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
3 * Copyright (C) Maxim Dounin
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
4 */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
5
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
6 #include <ngx_config.h>
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
7 #include <ngx_core.h>
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
8 #include <ngx_http.h>
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
9
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
10
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
11 typedef struct {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
12 ngx_flag_t enable;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
13 } ngx_http_compose_conf_t;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
14
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
15
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16 static void *ngx_http_compose_create_conf(ngx_conf_t *cf);
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17 static char *ngx_http_compose_merge_conf(ngx_conf_t *cf, void *parent,
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18 void *child);
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 static ngx_int_t ngx_http_compose_init(ngx_conf_t *cf);
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22 static ngx_command_t ngx_http_compose_commands[] = {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
24 { ngx_string("compose"),
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
25 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26 ngx_conf_set_flag_slot,
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27 NGX_HTTP_LOC_CONF_OFFSET,
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
28 offsetof(ngx_http_compose_conf_t, enable),
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
29 NULL },
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
30
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
31 ngx_null_command
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
32 };
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
33
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
34
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35 static ngx_http_module_t ngx_http_compose_module_ctx = {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 NULL, /* preconfiguration */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
37 ngx_http_compose_init, /* postconfiguration */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
38
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
39 NULL, /* create main configuration */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
40 NULL, /* init main configuration */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
41
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
42 NULL, /* create server configuration */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
43 NULL, /* merge server configuration */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
44
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
45 ngx_http_compose_create_conf, /* create location configuration */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
46 ngx_http_compose_merge_conf /* merge location configuration */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
47 };
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
48
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
49
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
50 ngx_module_t ngx_http_compose_filter_module = {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
51 NGX_MODULE_V1,
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
52 &ngx_http_compose_module_ctx, /* module context */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
53 ngx_http_compose_commands, /* module directives */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
54 NGX_HTTP_MODULE, /* module type */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
55 NULL, /* init master */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
56 NULL, /* init module */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
57 NULL, /* init process */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
58 NULL, /* init thread */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
59 NULL, /* exit thread */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
60 NULL, /* exit process */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
61 NULL, /* exit master */
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
62 NGX_MODULE_V1_PADDING
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
63 };
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
64
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
65
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
66 static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
67 static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
68
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
69
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
70 static ngx_int_t
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
71 ngx_http_compose_header_filter(ngx_http_request_t *r)
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
72 {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
73 ngx_http_compose_conf_t *conf;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
74
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
75 conf = ngx_http_get_module_loc_conf(r, ngx_http_compose_filter_module);
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
76
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
77 if (!conf->enable) {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
78 return ngx_http_next_header_filter(r);
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
79 }
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
80
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
81 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
82 "compose header filter");
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
83
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
84 return ngx_http_next_header_filter(r);
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
85 }
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
86
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
87
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
88 static ngx_int_t
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
89 ngx_http_compose_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
90 {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
91 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
92 "compose body filter");
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
93
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
94 return ngx_http_next_body_filter(r, in);
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
95 }
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
96
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
97
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
98 static void *
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
99 ngx_http_compose_create_conf(ngx_conf_t *cf)
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
100 {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
101 ngx_http_compose_conf_t *conf;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
102
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
103 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_compose_conf_t));
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
104 if (conf == NULL) {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
105 return NGX_CONF_ERROR;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
106 }
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
107
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
108 conf->enable = NGX_CONF_UNSET;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
109
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
110 return conf;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
111 }
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
112
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
113
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
114 static char *
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
115 ngx_http_compose_merge_conf(ngx_conf_t *cf, void *parent, void *child)
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
116 {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
117 ngx_http_compose_conf_t *prev = parent;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
118 ngx_http_compose_conf_t *conf = child;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
119
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
120 ngx_conf_merge_value(conf->enable, prev->enable, 0);
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
121
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
122 return NGX_CONF_OK;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
123 }
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
124
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
125
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
126 static ngx_int_t
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
127 ngx_http_compose_init(ngx_conf_t *cf)
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
128 {
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
129 ngx_http_next_header_filter = ngx_http_top_header_filter;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
130 ngx_http_top_header_filter = ngx_http_compose_header_filter;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
131
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
132 ngx_http_next_body_filter = ngx_http_top_body_filter;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
133 ngx_http_top_body_filter = ngx_http_compose_body_filter;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
134
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
135 return NGX_OK;
6535d94ae07d Compose filter module skeleton, currently does nothing.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
136 }