Index: trunk/debs/nginx/modules/nginx-udplog/ngx_http_udplog_module.c |
— | — | @@ -87,6 +87,8 @@ |
88 | 88 | ngx_http_variable_value_t *v, uintptr_t data); |
89 | 89 | static ngx_int_t ngx_http_udplog_escaped_user_agent_variable(ngx_http_request_t *r, |
90 | 90 | ngx_http_variable_value_t *v, uintptr_t data); |
| 91 | +static ngx_int_t ngx_http_udplog_escaped_content_type_variable(ngx_http_request_t *r, |
| 92 | + ngx_http_variable_value_t *v, uintptr_t data); |
91 | 93 | |
92 | 94 | static ngx_http_variable_t ngx_http_udplog_variables[] = { |
93 | 95 | { ngx_string("udplog_time"), NULL, ngx_http_udplog_time_variable, 0, |
— | — | @@ -95,6 +97,8 @@ |
96 | 98 | NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
97 | 99 | { ngx_string("udplog_escaped_user_agent"), NULL, ngx_http_udplog_escaped_user_agent_variable, 0, |
98 | 100 | NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
| 101 | + { ngx_string("udplog_escaped_content_type"), NULL, ngx_http_udplog_escaped_content_type_variable, 0, |
| 102 | + NGX_HTTP_VAR_NOCACHEABLE|NGX_HTTP_VAR_NOHASH, 0 }, |
99 | 103 | |
100 | 104 | { ngx_null_string, NULL, NULL, 0, 0, 0 } |
101 | 105 | }; |
— | — | @@ -242,6 +246,38 @@ |
243 | 247 | } |
244 | 248 | |
245 | 249 | static ngx_int_t |
| 250 | +ngx_http_udplog_escaped_content_type_variable(ngx_http_request_t *r, |
| 251 | + ngx_http_variable_value_t *v, uintptr_t data) |
| 252 | +{ |
| 253 | + u_char *ct; |
| 254 | + uintptr_t escape; |
| 255 | + size_t l; |
| 256 | + |
| 257 | + // Check that the content type string was processed. |
| 258 | + if(r->headers_in.content_type == NULL) { |
| 259 | + return NGX_ERROR; |
| 260 | + } |
| 261 | + |
| 262 | + ct = r->headers_in.content_type->value.data; |
| 263 | + l = r->headers_in.content_type->value.len; |
| 264 | + escape = 2 * ngx_escape_uri(NULL, ct, l, NGX_ESCAPE_URI); |
| 265 | + |
| 266 | + v->data = ngx_pnalloc(r->pool, l + escape); |
| 267 | + if (v->data == NULL) { |
| 268 | + return NGX_ERROR; |
| 269 | + } |
| 270 | + |
| 271 | + ngx_escape_uri(v->data, ct, l, NGX_ESCAPE_URI); |
| 272 | + |
| 273 | + v->len = l + escape; |
| 274 | + v->valid = 1; |
| 275 | + v->no_cacheable = 0; |
| 276 | + v->not_found = 0; |
| 277 | + |
| 278 | + return NGX_OK; |
| 279 | +} |
| 280 | + |
| 281 | +static ngx_int_t |
246 | 282 | ngx_http_udplog_add_variables(ngx_conf_t *cf) |
247 | 283 | { |
248 | 284 | ngx_http_variable_t *var, *v; |