@@ -37,9 +37,16 @@ char *ngx_http_fastcgi_cache_purge_conf(ngx_conf_t *cf,
37
37
ngx_command_t * cmd , void * conf );
38
38
char * ngx_http_proxy_cache_purge_conf (ngx_conf_t * cf ,
39
39
ngx_command_t * cmd , void * conf );
40
+ #if defined(nginx_version ) && (nginx_version >= 8040 )
41
+ char * ngx_http_uwsgi_cache_purge_conf (ngx_conf_t * cf ,
42
+ ngx_command_t * cmd , void * conf );
43
+ #endif
40
44
41
45
ngx_int_t ngx_http_fastcgi_cache_purge_handler (ngx_http_request_t * r );
42
46
ngx_int_t ngx_http_proxy_cache_purge_handler (ngx_http_request_t * r );
47
+ #if defined(nginx_version ) && (nginx_version >= 8040 )
48
+ ngx_int_t ngx_http_uwsgi_cache_purge_handler (ngx_http_request_t * r );
49
+ #endif
43
50
44
51
ngx_int_t ngx_http_cache_purge_handler (ngx_http_request_t * r ,
45
52
ngx_http_file_cache_t * cache , ngx_http_complex_value_t * cache_key );
@@ -63,6 +70,15 @@ static ngx_command_t ngx_http_cache_purge_module_commands[] = {
63
70
0 ,
64
71
NULL },
65
72
73
+ #if defined(nginx_version ) && (nginx_version >= 8040 )
74
+ { ngx_string ("uwsgi_cache_purge" ),
75
+ NGX_HTTP_LOC_CONF |NGX_CONF_TAKE2 ,
76
+ ngx_http_uwsgi_cache_purge_conf ,
77
+ NGX_HTTP_LOC_CONF_OFFSET ,
78
+ 0 ,
79
+ NULL },
80
+ #endif
81
+
66
82
ngx_null_command
67
83
};
68
84
@@ -111,6 +127,9 @@ CRLF "</center>" CRLF
111
127
112
128
extern ngx_module_t ngx_http_fastcgi_module ;
113
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
114
133
115
134
/* this is ugly workaround, find better solution... */
116
135
typedef struct {
@@ -183,6 +202,30 @@ typedef struct {
183
202
ngx_uint_t headers_hash_max_size ;
184
203
ngx_uint_t headers_hash_bucket_size ;
185
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
186
229
/* end of ugly workaround */
187
230
188
231
char *
@@ -292,6 +335,61 @@ ngx_http_proxy_cache_purge_conf(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
292
335
return NGX_CONF_OK ;
293
336
}
294
337
338
+ #if defined(nginx_version ) && (nginx_version >= 8040 )
339
+ char *
340
+ ngx_http_uwsgi_cache_purge_conf (ngx_conf_t * cf , ngx_command_t * cmd , void * conf )
341
+ {
342
+ ngx_http_compile_complex_value_t ccv ;
343
+ ngx_http_core_loc_conf_t * clcf ;
344
+ ngx_http_uwsgi_loc_conf_t * ulcf ;
345
+ ngx_str_t * value ;
346
+
347
+ ulcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_uwsgi_module );
348
+
349
+ /* check for duplicates / collisions */
350
+ if (ulcf -> upstream .cache != NGX_CONF_UNSET_PTR
351
+ && ulcf -> upstream .cache != NULL )
352
+ {
353
+ return "is either duplicate or collides with \"uwsgi_cache\"" ;
354
+ }
355
+
356
+ if (ulcf -> upstream .upstream || ulcf -> uwsgi_lengths ) {
357
+ return "is incompatible with \"uwsgi_pass\"" ;
358
+ }
359
+
360
+ if (ulcf -> upstream .store > 0 || ulcf -> upstream .store_lengths ) {
361
+ return "is incompatible with \"uwsgi_store\"" ;
362
+ }
363
+
364
+ value = cf -> args -> elts ;
365
+
366
+ /* set uwsgi_cache part */
367
+ ulcf -> upstream .cache = ngx_shared_memory_add (cf , & value [1 ], 0 ,
368
+ & ngx_http_uwsgi_module );
369
+ if (ulcf -> upstream .cache == NULL ) {
370
+ return NGX_CONF_ERROR ;
371
+ }
372
+
373
+ /* set uwsgi_cache_key part */
374
+ ngx_memzero (& ccv , sizeof (ngx_http_compile_complex_value_t ));
375
+
376
+ ccv .cf = cf ;
377
+ ccv .value = & value [2 ];
378
+ ccv .complex_value = & ulcf -> cache_key ;
379
+
380
+ if (ngx_http_compile_complex_value (& ccv ) != NGX_OK ) {
381
+ return NGX_CONF_ERROR ;
382
+ }
383
+
384
+ /* set handler */
385
+ clcf = ngx_http_conf_get_module_loc_conf (cf , ngx_http_core_module );
386
+
387
+ clcf -> handler = ngx_http_uwsgi_cache_purge_handler ;
388
+
389
+ return NGX_CONF_OK ;
390
+ }
391
+ #endif
392
+
295
393
ngx_int_t
296
394
ngx_http_fastcgi_cache_purge_handler (ngx_http_request_t * r )
297
395
{
@@ -322,6 +420,23 @@ ngx_http_proxy_cache_purge_handler(ngx_http_request_t *r)
322
420
& plcf -> cache_key );
323
421
}
324
422
423
+ #if defined(nginx_version ) && (nginx_version >= 8040 )
424
+ ngx_int_t
425
+ ngx_http_uwsgi_cache_purge_handler (ngx_http_request_t * r )
426
+ {
427
+ ngx_http_uwsgi_loc_conf_t * ulcf ;
428
+
429
+ if (!(r -> method & (NGX_HTTP_GET |NGX_HTTP_HEAD |NGX_HTTP_DELETE ))) {
430
+ return NGX_HTTP_NOT_ALLOWED ;
431
+ }
432
+
433
+ ulcf = ngx_http_get_module_loc_conf (r , ngx_http_uwsgi_module );
434
+
435
+ return ngx_http_cache_purge_handler (r , ulcf -> upstream .cache -> data ,
436
+ & ulcf -> cache_key );
437
+ }
438
+ #endif
439
+
325
440
ngx_int_t
326
441
ngx_http_cache_purge_handler (ngx_http_request_t * r ,
327
442
ngx_http_file_cache_t * cache , ngx_http_complex_value_t * cache_key )
0 commit comments