comparison src/http/ngx_http_upstream.c @ 4256:f83b47591642 stable-1.0

Merging r4198: 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 Igor Sysoev <igor@sysoev.ru>
date Tue, 01 Nov 2011 14:18:10 +0000
parents 2fad4d19ea4b
children 6af89b1b16e8
comparison
equal deleted inserted replaced
4255:edc216059175 4256:f83b47591642
358 358
359 359
360 ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[] = { 360 ngx_conf_bitmask_t ngx_http_upstream_ignore_headers_masks[] = {
361 { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT }, 361 { ngx_string("X-Accel-Redirect"), NGX_HTTP_UPSTREAM_IGN_XA_REDIRECT },
362 { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES }, 362 { ngx_string("X-Accel-Expires"), NGX_HTTP_UPSTREAM_IGN_XA_EXPIRES },
363 { ngx_string("X-Accel-Limit-Rate"), NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE },
364 { ngx_string("X-Accel-Buffering"), NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING },
365 { ngx_string("X-Accel-Charset"), NGX_HTTP_UPSTREAM_IGN_XA_CHARSET },
363 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES }, 366 { ngx_string("Expires"), NGX_HTTP_UPSTREAM_IGN_EXPIRES },
364 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL }, 367 { ngx_string("Cache-Control"), NGX_HTTP_UPSTREAM_IGN_CACHE_CONTROL },
365 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE }, 368 { ngx_string("Set-Cookie"), NGX_HTTP_UPSTREAM_IGN_SET_COOKIE },
366 { ngx_null_string, 0 } 369 { ngx_null_string, 0 }
367 }; 370 };
3266 3269
3267 static ngx_int_t 3270 static ngx_int_t
3268 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h, 3271 ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h,
3269 ngx_uint_t offset) 3272 ngx_uint_t offset)
3270 { 3273 {
3271 ngx_int_t n; 3274 ngx_int_t n;
3272 3275 ngx_http_upstream_t *u;
3273 r->upstream->headers_in.x_accel_limit_rate = h; 3276
3277 u = r->upstream;
3278 u->headers_in.x_accel_limit_rate = h;
3279
3280 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_LIMIT_RATE) {
3281 return NGX_OK;
3282 }
3274 3283
3275 n = ngx_atoi(h->value.data, h->value.len); 3284 n = ngx_atoi(h->value.data, h->value.len);
3276 3285
3277 if (n != NGX_ERROR) { 3286 if (n != NGX_ERROR) {
3278 r->limit_rate = (size_t) n; 3287 r->limit_rate = (size_t) n;
3284 3293
3285 static ngx_int_t 3294 static ngx_int_t
3286 ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h, 3295 ngx_http_upstream_process_buffering(ngx_http_request_t *r, ngx_table_elt_t *h,
3287 ngx_uint_t offset) 3296 ngx_uint_t offset)
3288 { 3297 {
3289 u_char c0, c1, c2; 3298 u_char c0, c1, c2;
3290 3299 ngx_http_upstream_t *u;
3291 if (r->upstream->conf->change_buffering) { 3300
3301 u = r->upstream;
3302
3303 if (u->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_BUFFERING) {
3304 return NGX_OK;
3305 }
3306
3307 if (u->conf->change_buffering) {
3292 3308
3293 if (h->value.len == 2) { 3309 if (h->value.len == 2) {
3294 c0 = ngx_tolower(h->value.data[0]); 3310 c0 = ngx_tolower(h->value.data[0]);
3295 c1 = ngx_tolower(h->value.data[1]); 3311 c1 = ngx_tolower(h->value.data[1]);
3296 3312
3297 if (c0 == 'n' && c1 == 'o') { 3313 if (c0 == 'n' && c1 == 'o') {
3298 r->upstream->buffering = 0; 3314 u->buffering = 0;
3299 } 3315 }
3300 3316
3301 } else if (h->value.len == 3) { 3317 } else if (h->value.len == 3) {
3302 c0 = ngx_tolower(h->value.data[0]); 3318 c0 = ngx_tolower(h->value.data[0]);
3303 c1 = ngx_tolower(h->value.data[1]); 3319 c1 = ngx_tolower(h->value.data[1]);
3304 c2 = ngx_tolower(h->value.data[2]); 3320 c2 = ngx_tolower(h->value.data[2]);
3305 3321
3306 if (c0 == 'y' && c1 == 'e' && c2 == 's') { 3322 if (c0 == 'y' && c1 == 'e' && c2 == 's') {
3307 r->upstream->buffering = 1; 3323 u->buffering = 1;
3308 } 3324 }
3309 } 3325 }
3310 } 3326 }
3311 3327
3312 return NGX_OK; 3328 return NGX_OK;
3315 3331
3316 static ngx_int_t 3332 static ngx_int_t
3317 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h, 3333 ngx_http_upstream_process_charset(ngx_http_request_t *r, ngx_table_elt_t *h,
3318 ngx_uint_t offset) 3334 ngx_uint_t offset)
3319 { 3335 {
3336 if (r->upstream->conf->ignore_headers & NGX_HTTP_UPSTREAM_IGN_XA_CHARSET) {
3337 return NGX_OK;
3338 }
3339
3320 r->headers_out.override_charset = &h->value; 3340 r->headers_out.override_charset = &h->value;
3321 3341
3322 return NGX_OK; 3342 return NGX_OK;
3323 } 3343 }
3324 3344