Mercurial > hg > nginx-quic
comparison src/http/ngx_http_upstream.c @ 4197:cf6a3467b5db
Additional headers for proxy/fastcgi/uwsgi/scgi_ignore_headers.
Now the following headers may be ignored as well: X-Accel-Limit-Rate,
X-Accel-Buffering, X-Accel-Charset.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 11 Oct 2011 18:10:49 +0000 |
parents | 75d2388bd6b9 |
children | 186f02886bed |
comparison
equal
deleted
inserted
replaced
4196:190ae1a7f917 | 4197:cf6a3467b5db |
---|---|
367 | 367 |
368 | 368 |
369 ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[] = { | 369 ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[] = { |
370 { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT }, | 370 { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT }, |
371 { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES }, | 371 { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES }, |
372 { ngx_string("X-Accel-Limit-Rate"), NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE }, | |
373 { ngx_string("X-Accel-Buffering"), NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING }, | |
374 { ngx_string("X-Accel-Charset"), NGX_HTTP_UPSTREAM_IGN_XA_CHARSET }, | |
372 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES }, | 375 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES }, |
373 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL }, | 376 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL }, |
374 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE }, | 377 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE }, |
375 { ngx_null_string, 0 } | 378 { ngx_null_string, 0 } |
376 }; | 379 }; |
3326 | 3329 |
3327 static ngx_int_t | 3330 static ngx_int_t |
3328 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, | 3331 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, |
3329 ngx_uint_t offset) | 3332 ngx_uint_t offset) |
3330 { | 3333 { |
3331 ngx_int_t n; | 3334 ngx_int_t n; |
3332 | 3335 ngx_http_upstream_t *u; |
3333 r->upstream->headers_in.x_accel_limit_rate = h; | 3336 |
3337 u = r->upstream; | |
3338 u->headers_in.x_accel_limit_rate = h; | |
3339 | |
3340 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE) { | |
3341 return NGX_OK; | |
3342 } | |
3334 | 3343 |
3335 n = ngx_atoi(h->value.data, h->value.len); | 3344 n = ngx_atoi(h->value.data, h->value.len); |
3336 | 3345 |
3337 if (n != NGX_ERROR) { | 3346 if (n != NGX_ERROR) { |
3338 r->limit_rate = (size_t) n; | 3347 r->limit_rate = (size_t) n; |
3344 | 3353 |
3345 static ngx_int_t | 3354 static ngx_int_t |
3346 ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, | 3355 ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, |
3347 ngx_uint_t offset) | 3356 ngx_uint_t offset) |
3348 { | 3357 { |
3349 u_char c0, c1, c2; | 3358 u_char c0, c1, c2; |
3350 | 3359 ngx_http_upstream_t *u; |
3351 if (r->upstream->conf->change_buffering) { | 3360 |
3361 u = r->upstream; | |
3362 | |
3363 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING) { | |
3364 return NGX_OK; | |
3365 } | |
3366 | |
3367 if (u->conf->change_buffering) { | |
3352 | 3368 |
3353 if (h->value.len == 2) { | 3369 if (h->value.len == 2) { |
3354 c0 = ngx_tolower(h->value.data[0]); | 3370 c0 = ngx_tolower(h->value.data[0]); |
3355 c1 = ngx_tolower(h->value.data[1]); | 3371 c1 = ngx_tolower(h->value.data[1]); |
3356 | 3372 |
3357 if (c0 == 'n' && c1 == 'o') { | 3373 if (c0 == 'n' && c1 == 'o') { |
3358 r->upstream->buffering = 0; | 3374 u->buffering = 0; |
3359 } | 3375 } |
3360 | 3376 |
3361 } else if (h->value.len == 3) { | 3377 } else if (h->value.len == 3) { |
3362 c0 = ngx_tolower(h->value.data[0]); | 3378 c0 = ngx_tolower(h->value.data[0]); |
3363 c1 = ngx_tolower(h->value.data[1]); | 3379 c1 = ngx_tolower(h->value.data[1]); |
3364 c2 = ngx_tolower(h->value.data[2]); | 3380 c2 = ngx_tolower(h->value.data[2]); |
3365 | 3381 |
3366 if (c0 == 'y' && c1 == 'e' && c2 == 's') { | 3382 if (c0 == 'y' && c1 == 'e' && c2 == 's') { |
3367 r->upstream->buffering = 1; | 3383 u->buffering = 1; |
3368 } | 3384 } |
3369 } | 3385 } |
3370 } | 3386 } |
3371 | 3387 |
3372 return NGX_OK; | 3388 return NGX_OK; |
3375 | 3391 |
3376 static ngx_int_t | 3392 static ngx_int_t |
3377 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, | 3393 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, |
3378 ngx_uint_t offset) | 3394 ngx_uint_t offset) |
3379 { | 3395 { |
3396 if (r->upstream->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_CHARSET) { | |
3397 return NGX_OK; | |
3398 } | |
3399 | |
3380 r->headers_out.override_charset = &h->value; | 3400 r->headers_out.override_charset = &h->value; |
3381 | 3401 |
3382 return NGX_OK; | 3402 return NGX_OK; |
3383 } | 3403 } |
3384 | 3404 |