comparison src/http/ngx_http_upstream.c @ 8029:e0027c8438b0

Upstream: simplified Content-Encoding handling. Since introduction of offset handling in ngx_http_upstream_copy_header_line() in revision 573:58475592100c, the ngx_http_upstream_copy_content_encoding() function is no longer needed, as its behaviour is exactly equivalent to ngx_http_upstream_copy_header_line() with appropriate offset. As such, the ngx_http_upstream_copy_content_encoding() function was removed. Further, the u->headers_in.content_encoding field is not used anywhere, so it was removed as well. Further, Content-Encoding handling no longer depends on NGX_HTTP_GZIP, as it can be used even without any gzip handling compiled in (for example, in the charset filter).
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 30 May 2022 21:25:42 +0300
parents 27d12017f300
children cdc2724858ca
comparison
equal deleted inserted replaced
8028:27d12017f300 8029:e0027c8438b0
145 static ngx_int_t ngx_http_upstream_rewrite_set_cookie(ngx_http_request_t *r, 145 static ngx_int_t ngx_http_upstream_rewrite_set_cookie(ngx_http_request_t *r,
146 ngx_table_elt_t *h, ngx_uint_t offset); 146 ngx_table_elt_t *h, ngx_uint_t offset);
147 static ngx_int_t ngx_http_upstream_copy_allow_ranges(ngx_http_request_t *r, 147 static ngx_int_t ngx_http_upstream_copy_allow_ranges(ngx_http_request_t *r,
148 ngx_table_elt_t *h, ngx_uint_t offset); 148 ngx_table_elt_t *h, ngx_uint_t offset);
149 149
150 #if (NGX_HTTP_GZIP)
151 static ngx_int_t ngx_http_upstream_copy_content_encoding(ngx_http_request_t *r,
152 ngx_table_elt_t *h, ngx_uint_t offset);
153 #endif
154
155 static ngx_int_t ngx_http_upstream_add_variables(ngx_conf_t *cf); 150 static ngx_int_t ngx_http_upstream_add_variables(ngx_conf_t *cf);
156 static ngx_int_t ngx_http_upstream_addr_variable(ngx_http_request_t *r, 151 static ngx_int_t ngx_http_upstream_addr_variable(ngx_http_request_t *r,
157 ngx_http_variable_value_t *v, uintptr_t data); 152 ngx_http_variable_value_t *v, uintptr_t data);
158 static ngx_int_t ngx_http_upstream_status_variable(ngx_http_request_t *r, 153 static ngx_int_t ngx_http_upstream_status_variable(ngx_http_request_t *r,
159 ngx_http_variable_value_t *v, uintptr_t data); 154 ngx_http_variable_value_t *v, uintptr_t data);
314 309
315 { ngx_string("Transfer-Encoding"), 310 { ngx_string("Transfer-Encoding"),
316 ngx_http_upstream_process_transfer_encoding, 0, 311 ngx_http_upstream_process_transfer_encoding, 0,
317 ngx_http_upstream_ignore_header_line, 0, 0 }, 312 ngx_http_upstream_ignore_header_line, 0, 0 },
318 313
319 #if (NGX_HTTP_GZIP)
320 { ngx_string("Content-Encoding"), 314 { ngx_string("Content-Encoding"),
321 ngx_http_upstream_process_header_line, 315 ngx_http_upstream_ignore_header_line, 0,
322 offsetof(ngx_http_upstream_headers_in_t, content_encoding), 316 ngx_http_upstream_copy_header_line,
323 ngx_http_upstream_copy_content_encoding, 0, 0 }, 317 offsetof(ngx_http_headers_out_t, content_encoding), 0 },
324 #endif
325 318
326 { ngx_null_string, NULL, 0, NULL, 0, 0 } 319 { ngx_null_string, NULL, 0, NULL, 0, 0 }
327 }; 320 };
328 321
329 322
5347 5340
5348 return NGX_OK; 5341 return NGX_OK;
5349 } 5342 }
5350 5343
5351 5344
5352 #if (NGX_HTTP_GZIP)
5353
5354 static ngx_int_t
5355 ngx_http_upstream_copy_content_encoding(ngx_http_request_t *r,
5356 ngx_table_elt_t *h, ngx_uint_t offset)
5357 {
5358 ngx_table_elt_t *ho;
5359
5360 ho = ngx_list_push(&r->headers_out.headers);
5361 if (ho == NULL) {
5362 return NGX_ERROR;
5363 }
5364
5365 *ho = *h;
5366
5367 r->headers_out.content_encoding = ho;
5368
5369 return NGX_OK;
5370 }
5371
5372 #endif
5373
5374
5375 static ngx_int_t 5345 static ngx_int_t
5376 ngx_http_upstream_add_variables(ngx_conf_t *cf) 5346 ngx_http_upstream_add_variables(ngx_conf_t *cf)
5377 { 5347 {
5378 ngx_http_variable_t *var, *v; 5348 ngx_http_variable_t *var, *v;
5379 5349