comparison src/http/modules/proxy/ngx_http_proxy_header.c @ 170:c42be4185301

nginx-0.0.1-2003-11-03-01:56:18 import
author Igor Sysoev <igor@sysoev.ru>
date Sun, 02 Nov 2003 22:56:18 +0000
parents
children caa57ddf6d77
comparison
equal deleted inserted replaced
169:edf29bb717da 170:c42be4185301
1
2 #include <ngx_config.h>
3 #include <ngx_core.h>
4 #include <ngx_http.h>
5 #include <ngx_http_proxy_handler.h>
6
7
8 int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p,
9 ngx_http_proxy_headers_in_t *headers_in)
10 {
11 int i;
12 ngx_table_elt_t *ho, *h;
13 ngx_http_request_t *r;
14
15 r = p->request;
16
17 h = headers_in->headers->elts;
18 for (i = 0; i < headers_in->headers->nelts; i++) {
19
20 if (&h[i] == headers_in->connection) {
21 continue;
22 }
23
24 if (p->accel) {
25 if (&h[i] == headers_in->date
26 || &h[i] == headers_in->accept_ranges) {
27 continue;
28 }
29
30 if (&h[i] == headers_in->server && !p->lcf->pass_server) {
31 continue;
32 }
33 }
34
35 if (&h[i] == headers_in->content_type) {
36 r->headers_out.content_type = &h[i];
37 r->headers_out.content_type->key.len = 0;
38 continue;
39 }
40
41 if (!(ho = ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
42 {
43 return NGX_ERROR;
44 }
45
46 *ho = h[i];
47
48 /*
49 * ngx_http_header_filter() does not handle specially
50 * the following headers if they are set:
51 * r->headers_out.server,
52 * r->headers_out.date,
53 * r->headers_out.content_length
54 */
55
56 if (&h[i] == headers_in->server) {
57 r->headers_out.server = ho;
58 continue;
59 }
60
61 if (&h[i] == headers_in->date) {
62 r->headers_out.date = ho;
63 continue;
64 }
65
66 if (&h[i] == headers_in->content_length) {
67 r->headers_out.content_length = ho;
68 r->headers_out.content_length_n = ngx_atoi(ho->value.data,
69 ho->value.len);
70 continue;
71 }
72 }
73
74 return NGX_OK;
75 }