comparison src/http/modules/proxy/ngx_http_proxy_header.c @ 294:5cfd65b8b0a7

nginx-0.0.3-2004-03-23-09:01:52 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 23 Mar 2004 06:01:52 +0000
parents 87e73f067470
children 39b6f2df45c0
comparison
equal deleted inserted replaced
293:ec3c049681fd 294:5cfd65b8b0a7
15 ngx_table_elt_t *ho, *h; 15 ngx_table_elt_t *ho, *h;
16 ngx_http_request_t *r; 16 ngx_http_request_t *r;
17 17
18 r = p->request; 18 r = p->request;
19 19
20 h = headers_in->headers->elts; 20 h = headers_in->headers.elts;
21 for (i = 0; i < headers_in->headers->nelts; i++) { 21 for (i = 0; i < headers_in->headers.nelts; i++) {
22 22
23 if (&h[i] == headers_in->connection) { 23 if (&h[i] == headers_in->connection) {
24 continue; 24 continue;
25 } 25 }
26 26
96 96
97 static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p, 97 static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p,
98 ngx_table_elt_t *loc) 98 ngx_table_elt_t *loc)
99 { 99 {
100 u_char *last; 100 u_char *last;
101 ngx_table_elt_t *location;
101 ngx_http_request_t *r; 102 ngx_http_request_t *r;
102 ngx_http_proxy_upstream_conf_t *uc; 103 ngx_http_proxy_upstream_conf_t *uc;
103 104
104 r = p->request; 105 r = p->request;
105 uc = p->lcf->upstream; 106 uc = p->lcf->upstream;
106 107
107 r->headers_out.location = ngx_http_add_header(&r->headers_out, 108 location = ngx_http_add_header(&r->headers_out, ngx_http_headers_out);
108 ngx_http_headers_out); 109 if (location == NULL) {
109 if (r->headers_out.location == NULL) {
110 return NGX_ERROR; 110 return NGX_ERROR;
111 } 111 }
112
113 /*
114 * we do not set r->headers_out.location to avoid the handling
115 * the local redirects without a host name by ngx_http_header_filter()
116 */
117
118 #if 0
119 r->headers_out.location = location;
120 #endif
112 121
113 if (uc->url.len > loc->value.len 122 if (uc->url.len > loc->value.len
114 || ngx_rstrncmp(loc->value.data, uc->url.data, uc->url.len) != 0) 123 || ngx_rstrncmp(loc->value.data, uc->url.data, uc->url.len) != 0)
115 { 124 {
116 *r->headers_out.location = *loc; 125 *location = *loc;
117 return NGX_OK; 126 return NGX_OK;
118 } 127 }
119 128
120 /* TODO: proxy_reverse */ 129 /* TODO: proxy_reverse */
121 130
122 r->headers_out.location->value.len = uc->location->len 131 location->value.len = uc->location->len
123 + (loc->value.len - uc->url.len) + 1; 132 + (loc->value.len - uc->url.len) + 1;
124 r->headers_out.location->value.data = 133 if (!(location->value.data = ngx_palloc(r->pool, location->value.len))) {
125 ngx_palloc(r->pool, r->headers_out.location->value.len);
126
127 if (r->headers_out.location->value.data == NULL) {
128 return NGX_ERROR; 134 return NGX_ERROR;
129 } 135 }
130 136
131 last = ngx_cpymem(r->headers_out.location->value.data, 137 last = ngx_cpymem(location->value.data,
132 uc->location->data, uc->location->len); 138 uc->location->data, uc->location->len);
133 139
134 ngx_cpystrn(last, loc->value.data + uc->url.len, 140 ngx_cpystrn(last, loc->value.data + uc->url.len,
135 loc->value.len - uc->url.len + 1); 141 loc->value.len - uc->url.len + 1);
136 142