26
26
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
27
*/
28
28
29
+ #include <nginx.h>
29
30
#include <ngx_config.h>
30
31
#include <ngx_core.h>
31
32
#include <ngx_http.h>
32
- #include <nginx.h>
33
+
33
34
34
35
#if (NGX_HTTP_CACHE )
35
36
37
+ # if (NGX_HTTP_FASTCGI )
36
38
char * ngx_http_fastcgi_cache_purge_conf (ngx_conf_t * cf ,
37
39
ngx_command_t * cmd , void * conf );
40
+ ngx_int_t ngx_http_fastcgi_cache_purge_handler (ngx_http_request_t * r );
41
+ # endif /* NGX_HTTP_FASTCGI */
42
+
43
+ # if (NGX_HTTP_PROXY )
38
44
char * ngx_http_proxy_cache_purge_conf (ngx_conf_t * cf ,
39
45
ngx_command_t * cmd , void * conf );
40
- #if defined(nginx_version ) && (nginx_version >= 8040 )
46
+ ngx_int_t ngx_http_proxy_cache_purge_handler (ngx_http_request_t * r );
47
+ # endif /* NGX_HTTP_PROXY */
48
+
49
+ # if (NGX_HTTP_UWSGI )
41
50
char * ngx_http_uwsgi_cache_purge_conf (ngx_conf_t * cf ,
42
51
ngx_command_t * cmd , void * conf );
43
- #endif
44
-
45
- ngx_int_t ngx_http_fastcgi_cache_purge_handler (ngx_http_request_t * r );
46
- ngx_int_t ngx_http_proxy_cache_purge_handler (ngx_http_request_t * r );
47
- #if defined(nginx_version ) && (nginx_version >= 8040 )
48
52
ngx_int_t ngx_http_uwsgi_cache_purge_handler (ngx_http_request_t * r );
49
- #endif
53
+ # endif /* NGX_HTTP_UWSGI */
50
54
51
55
ngx_int_t ngx_http_cache_purge_handler (ngx_http_request_t * r ,
52
56
ngx_http_file_cache_t * cache , ngx_http_complex_value_t * cache_key );
@@ -56,28 +60,32 @@ ngx_int_t ngx_http_file_cache_purge(ngx_http_request_t *r,
56
60
57
61
static ngx_command_t ngx_http_cache_purge_module_commands [] = {
58
62
63
+ # if (NGX_HTTP_FASTCGI )
59
64
{ ngx_string ("fastcgi_cache_purge" ),
60
65
NGX_HTTP_LOC_CONF |NGX_CONF_TAKE2 ,
61
66
ngx_http_fastcgi_cache_purge_conf ,
62
67
NGX_HTTP_LOC_CONF_OFFSET ,
63
68
0 ,
64
69
NULL },
70
+ # endif /* NGX_HTTP_FASTCGI */
65
71
72
+ # if (NGX_HTTP_PROXY )
66
73
{ ngx_string ("proxy_cache_purge" ),
67
74
NGX_HTTP_LOC_CONF |NGX_CONF_TAKE2 ,
68
75
ngx_http_proxy_cache_purge_conf ,
69
76
NGX_HTTP_LOC_CONF_OFFSET ,
70
77
0 ,
71
78
NULL },
79
+ # endif /* NGX_HTTP_PROXY */
72
80
73
- #if defined( nginx_version ) && ( nginx_version >= 8040 )
81
+ # if ( NGX_HTTP_UWSGI )
74
82
{ ngx_string ("uwsgi_cache_purge" ),
75
83
NGX_HTTP_LOC_CONF |NGX_CONF_TAKE2 ,
76
84
ngx_http_uwsgi_cache_purge_conf ,
77
85
NGX_HTTP_LOC_CONF_OFFSET ,
78
86
0 ,
79
87
NULL },
80
- #endif
88
+ # endif /* NGX_HTTP_UWSGI */
81
89
82
90
ngx_null_command
83
91
};
@@ -125,13 +133,9 @@ CRLF "</center>" CRLF
125
133
"</html>" CRLF
126
134
;
127
135
136
+ # if (NGX_HTTP_FASTCGI )
128
137
extern ngx_module_t ngx_http_fastcgi_module ;
129
- extern ngx_module_t ngx_http_proxy_module ;
130
- #if defined(nginx_version ) && (nginx_version >= 8040 )
131
- extern ngx_module_t ngx_http_uwsgi_module ;
132
- #endif
133
138
134
- /* this is ugly workaround, find better solution... */
135
139
typedef struct {
136
140
ngx_http_upstream_conf_t upstream ;
137
141
@@ -146,88 +150,19 @@ typedef struct {
146
150
ngx_array_t * fastcgi_lengths ;
147
151
ngx_array_t * fastcgi_values ;
148
152
149
- #if defined(nginx_version ) && (nginx_version >= 8040 )
153
+ # if defined(nginx_version ) && (nginx_version >= 8040 )
150
154
ngx_hash_t headers_hash ;
151
155
ngx_uint_t header_params ;
152
- #endif
156
+ # endif /* nginx_version >= 8040 */
153
157
154
158
ngx_http_complex_value_t cache_key ;
155
159
156
- #if (NGX_PCRE )
160
+ # if (NGX_PCRE )
157
161
ngx_regex_t * split_regex ;
158
162
ngx_str_t split_name ;
159
- #endif
163
+ # endif /* NGX_PCRE */
160
164
} ngx_http_fastcgi_loc_conf_t ;
161
165
162
- typedef struct {
163
- ngx_str_t key_start ;
164
- ngx_str_t schema ;
165
- ngx_str_t host_header ;
166
- ngx_str_t port ;
167
- ngx_str_t uri ;
168
- } ngx_http_proxy_vars_t ;
169
-
170
- typedef struct {
171
- ngx_http_upstream_conf_t upstream ;
172
-
173
- ngx_array_t * flushes ;
174
- ngx_array_t * body_set_len ;
175
- ngx_array_t * body_set ;
176
- ngx_array_t * headers_set_len ;
177
- ngx_array_t * headers_set ;
178
- ngx_hash_t headers_set_hash ;
179
-
180
- ngx_array_t * headers_source ;
181
- #if defined(nginx_version ) && (nginx_version < 8040 )
182
- ngx_array_t * headers_names ;
183
- #endif
184
-
185
- ngx_array_t * proxy_lengths ;
186
- ngx_array_t * proxy_values ;
187
-
188
- ngx_array_t * redirects ;
189
-
190
- ngx_str_t body_source ;
191
-
192
- ngx_str_t method ;
193
- ngx_str_t location ;
194
- ngx_str_t url ;
195
-
196
- ngx_http_complex_value_t cache_key ;
197
-
198
- ngx_http_proxy_vars_t vars ;
199
-
200
- ngx_flag_t redirect ;
201
-
202
- ngx_uint_t headers_hash_max_size ;
203
- ngx_uint_t headers_hash_bucket_size ;
204
- } ngx_http_proxy_loc_conf_t ;
205
-
206
- #if defined(nginx_version ) && (nginx_version >= 8040 )
207
- typedef struct {
208
- ngx_http_upstream_conf_t upstream ;
209
-
210
- ngx_array_t * flushes ;
211
- ngx_array_t * params_len ;
212
- ngx_array_t * params ;
213
- ngx_array_t * params_source ;
214
-
215
- ngx_hash_t headers_hash ;
216
- ngx_uint_t header_params ;
217
-
218
- ngx_array_t * uwsgi_lengths ;
219
- ngx_array_t * uwsgi_values ;
220
-
221
- ngx_http_complex_value_t cache_key ;
222
-
223
- ngx_str_t uwsgi_string ;
224
-
225
- ngx_uint_t modifier1 ;
226
- ngx_uint_t modifier2 ;
227
- } ngx_http_uwsgi_loc_conf_t ;
228
- #endif
229
- /* end of ugly workaround */
230
-
231
166
char *
232
167
ngx_http_fastcgi_cache_purge_conf (ngx_conf_t * cf , ngx_command_t * cmd ,
233
168
void * conf )
@@ -282,6 +217,69 @@ ngx_http_fastcgi_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd,
282
217
return NGX_CONF_OK ;
283
218
}
284
219
220
+ ngx_int_t
221
+ ngx_http_fastcgi_cache_purge_handler (ngx_http_request_t * r )
222
+ {
223
+ ngx_http_fastcgi_loc_conf_t * flcf ;
224
+
225
+ if (!(r -> method & (NGX_HTTP_GET |NGX_HTTP_HEAD |NGX_HTTP_DELETE ))) {
226
+ return NGX_HTTP_NOT_ALLOWED ;
227
+ }
228
+
229
+ flcf = ngx_http_get_module_loc_conf (r , ngx_http_fastcgi_module );
230
+
231
+ return ngx_http_cache_purge_handler (r , flcf -> upstream .cache -> data ,
232
+ & flcf -> cache_key );
233
+ }
234
+ # endif /* NGX_HTTP_FASTCGI */
235
+
236
+ # if (NGX_HTTP_PROXY )
237
+ extern ngx_module_t ngx_http_proxy_module ;
238
+
239
+ typedef struct {
240
+ ngx_str_t key_start ;
241
+ ngx_str_t schema ;
242
+ ngx_str_t host_header ;
243
+ ngx_str_t port ;
244
+ ngx_str_t uri ;
245
+ } ngx_http_proxy_vars_t ;
246
+
247
+ typedef struct {
248
+ ngx_http_upstream_conf_t upstream ;
249
+
250
+ ngx_array_t * flushes ;
251
+ ngx_array_t * body_set_len ;
252
+ ngx_array_t * body_set ;
253
+ ngx_array_t * headers_set_len ;
254
+ ngx_array_t * headers_set ;
255
+ ngx_hash_t headers_set_hash ;
256
+
257
+ ngx_array_t * headers_source ;
258
+ # if defined(nginx_version ) && (nginx_version < 8040 )
259
+ ngx_array_t * headers_names ;
260
+ # endif /* nginx_version < 8040 */
261
+
262
+ ngx_array_t * proxy_lengths ;
263
+ ngx_array_t * proxy_values ;
264
+
265
+ ngx_array_t * redirects ;
266
+
267
+ ngx_str_t body_source ;
268
+
269
+ ngx_str_t method ;
270
+ ngx_str_t location ;
271
+ ngx_str_t url ;
272
+
273
+ ngx_http_complex_value_t cache_key ;
274
+
275
+ ngx_http_proxy_vars_t vars ;
276
+
277
+ ngx_flag_t redirect ;
278
+
279
+ ngx_uint_t headers_hash_max_size ;
280
+ ngx_uint_t headers_hash_bucket_size ;
281
+ } ngx_http_proxy_loc_conf_t ;
282
+
285
283
char *
286
284
ngx_http_proxy_cache_purge_conf (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
287
285
{
@@ -335,7 +333,47 @@ ngx_http_proxy_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
335
333
return NGX_CONF_OK ;
336
334
}
337
335
338
- #if defined(nginx_version ) && (nginx_version >= 8040 )
336
+ ngx_int_t
337
+ ngx_http_proxy_cache_purge_handler (ngx_http_request_t * r )
338
+ {
339
+ ngx_http_proxy_loc_conf_t * plcf ;
340
+
341
+ if (!(r -> method & (NGX_HTTP_GET |NGX_HTTP_HEAD |NGX_HTTP_DELETE ))) {
342
+ return NGX_HTTP_NOT_ALLOWED ;
343
+ }
344
+
345
+ plcf = ngx_http_get_module_loc_conf (r , ngx_http_proxy_module );
346
+
347
+ return ngx_http_cache_purge_handler (r , plcf -> upstream .cache -> data ,
348
+ & plcf -> cache_key );
349
+ }
350
+ # endif /* NGX_HTTP_PROXY */
351
+
352
+ # if (NGX_HTTP_UWSGI )
353
+ extern ngx_module_t ngx_http_uwsgi_module ;
354
+
355
+ typedef struct {
356
+ ngx_http_upstream_conf_t upstream ;
357
+
358
+ ngx_array_t * flushes ;
359
+ ngx_array_t * params_len ;
360
+ ngx_array_t * params ;
361
+ ngx_array_t * params_source ;
362
+
363
+ ngx_hash_t headers_hash ;
364
+ ngx_uint_t header_params ;
365
+
366
+ ngx_array_t * uwsgi_lengths ;
367
+ ngx_array_t * uwsgi_values ;
368
+
369
+ ngx_http_complex_value_t cache_key ;
370
+
371
+ ngx_str_t uwsgi_string ;
372
+
373
+ ngx_uint_t modifier1 ;
374
+ ngx_uint_t modifier2 ;
375
+ } ngx_http_uwsgi_loc_conf_t ;
376
+
339
377
char *
340
378
ngx_http_uwsgi_cache_purge_conf (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
341
379
{
@@ -388,39 +426,7 @@ ngx_http_uwsgi_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
388
426
389
427
return NGX_CONF_OK ;
390
428
}
391
- #endif
392
-
393
- ngx_int_t
394
- ngx_http_fastcgi_cache_purge_handler (ngx_http_request_t * r )
395
- {
396
- ngx_http_fastcgi_loc_conf_t * flcf ;
397
-
398
- if (!(r -> method & (NGX_HTTP_GET |NGX_HTTP_HEAD |NGX_HTTP_DELETE ))) {
399
- return NGX_HTTP_NOT_ALLOWED ;
400
- }
401
-
402
- flcf = ngx_http_get_module_loc_conf (r , ngx_http_fastcgi_module );
403
-
404
- return ngx_http_cache_purge_handler (r , flcf -> upstream .cache -> data ,
405
- & flcf -> cache_key );
406
- }
407
-
408
- ngx_int_t
409
- ngx_http_proxy_cache_purge_handler (ngx_http_request_t * r )
410
- {
411
- ngx_http_proxy_loc_conf_t * plcf ;
412
-
413
- if (!(r -> method & (NGX_HTTP_GET |NGX_HTTP_HEAD |NGX_HTTP_DELETE ))) {
414
- return NGX_HTTP_NOT_ALLOWED ;
415
- }
416
-
417
- plcf = ngx_http_get_module_loc_conf (r , ngx_http_proxy_module );
418
-
419
- return ngx_http_cache_purge_handler (r , plcf -> upstream .cache -> data ,
420
- & plcf -> cache_key );
421
- }
422
429
423
- #if defined(nginx_version ) && (nginx_version >= 8040 )
424
430
ngx_int_t
425
431
ngx_http_uwsgi_cache_purge_handler (ngx_http_request_t * r )
426
432
{
@@ -435,7 +441,7 @@ ngx_http_uwsgi_cache_purge_handler(ngx_http_request_t *r)
435
441
return ngx_http_cache_purge_handler (r , ulcf -> upstream .cache -> data ,
436
442
& ulcf -> cache_key );
437
443
}
438
- #endif
444
+ # endif /* NGX_HTTP_UWSGI */
439
445
440
446
ngx_int_t
441
447
ngx_http_cache_purge_handler (ngx_http_request_t * r ,
0 commit comments