diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-09-05 23:54:02 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-09-05 23:54:02 +0400 |
commit | 980a92472cc30271ad7e88eb2dcc43f00e984d4d (patch) | |
tree | b8940cd9e6b8859c78e3c023c1373bae02371f2e /src/http/modules | |
parent | b9e344175f4e971284aa14c8fe685936a4957d52 (diff) |
nginx-0.0.10-2004-09-05-23:54:02 import
Diffstat (limited to 'src/http/modules')
-rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 3 | ||||
-rw-r--r-- | src/http/modules/ngx_http_headers_filter.c | 6 | ||||
-rw-r--r-- | src/http/modules/ngx_http_range_filter.c | 24 | ||||
-rw-r--r-- | src/http/modules/ngx_http_static_handler.c | 3 | ||||
-rw-r--r-- | src/http/modules/ngx_http_status_handler.c | 3 | ||||
-rw-r--r-- | src/http/modules/ngx_http_userid_filter.c | 28 | ||||
-rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_upstream.c | 32 |
7 files changed, 58 insertions, 41 deletions
diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index 611f157ef..8fbf3a9a3 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -297,8 +297,7 @@ static ngx_int_t ngx_http_gzip_header_filter(ngx_http_request_t *r) sizeof(ngx_http_gzip_ctx_t), NGX_ERROR); ctx->request = r; - r->headers_out.content_encoding = - ngx_http_add_header(&r->headers_out, ngx_http_headers_out); + r->headers_out.content_encoding = ngx_push_list(&r->headers_out.headers); if (r->headers_out.content_encoding == NULL) { return NGX_ERROR; } diff --git a/src/http/modules/ngx_http_headers_filter.c b/src/http/modules/ngx_http_headers_filter.c index 7dcb88d10..b821c0db1 100644 --- a/src/http/modules/ngx_http_headers_filter.c +++ b/src/http/modules/ngx_http_headers_filter.c @@ -75,15 +75,13 @@ static ngx_int_t ngx_http_headers_filter(ngx_http_request_t *r) if (conf->expires != NGX_HTTP_EXPIRES_OFF) { - expires = ngx_http_add_header(&r->headers_out, ngx_http_headers_out); - if (expires == NULL) { + if (!(expires = ngx_push_list(&r->headers_out.headers))) { return NGX_ERROR; } r->headers_out.expires = expires; - cc = ngx_http_add_header(&r->headers_out, ngx_http_headers_out); - if (cc == NULL) { + if (!(cc = ngx_push_list(&r->headers_out.headers))) { return NGX_ERROR; } diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c index 8d3e3dd93..913c90a96 100644 --- a/src/http/modules/ngx_http_range_filter.c +++ b/src/http/modules/ngx_http_range_filter.c @@ -123,9 +123,8 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r) || ngx_strncasecmp(r->headers_in.range->value.data, "bytes=", 6) != 0) { - if (!(r->headers_out.accept_ranges = - ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) - { + r->headers_out.accept_ranges = ngx_push_list(&r->headers_out.headers); + if (r->headers_out.accept_ranges == NULL) { return NGX_ERROR; } @@ -245,18 +244,19 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r) r->headers_out.status = rc; r->headers_out.ranges.nelts = 0; - if (!(r->headers_out.content_range = - ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) - { + r->headers_out.content_range = ngx_push_list(&r->headers_out.headers); + if (r->headers_out.content_range == NULL) { return NGX_ERROR; } r->headers_out.content_range->key.len = sizeof("Content-Range") - 1; r->headers_out.content_range->key.data = (u_char *) "Content-Range"; - ngx_test_null(r->headers_out.content_range->value.data, - ngx_palloc(r->pool, 8 + 20 + 1), - NGX_ERROR); + r->headers_out.content_range->value.data = + ngx_palloc(r->pool, 8 + 20 + 1); + if (r->headers_out.content_range->value.data == NULL) { + return NGX_ERROR; + } r->headers_out.content_range->value.len = ngx_snprintf((char *) r->headers_out.content_range->value.data, @@ -276,9 +276,9 @@ static ngx_int_t ngx_http_range_header_filter(ngx_http_request_t *r) if (r->headers_out.ranges.nelts == 1) { - if (!(r->headers_out.content_range = - ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) - { + r->headers_out.content_range = + ngx_push_list(&r->headers_out.headers); + if (r->headers_out.content_range == NULL) { return NGX_ERROR; } diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c index cf942ad24..ad7d9cf53 100644 --- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -341,8 +341,7 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r) *last++ = '/'; *last = '\0'; - if (!(r->headers_out.location = - ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) + if (!(r->headers_out.location = ngx_push_list(&r->headers_out.headers))) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } diff --git a/src/http/modules/ngx_http_status_handler.c b/src/http/modules/ngx_http_status_handler.c index 57d7aa077..97492ebb9 100644 --- a/src/http/modules/ngx_http_status_handler.c +++ b/src/http/modules/ngx_http_status_handler.c @@ -70,8 +70,7 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) return rc; } - if (!(r->headers_out.content_type = - ngx_http_add_header(&r->headers_out, ngx_http_headers_out))) + if (!(r->headers_out.content_type = ngx_push_list(&r->headers_out.headers))) { return NGX_HTTP_INTERNAL_SERVER_ERROR; } diff --git a/src/http/modules/ngx_http_userid_filter.c b/src/http/modules/ngx_http_userid_filter.c index ba0d5838e..842719e52 100644 --- a/src/http/modules/ngx_http_userid_filter.c +++ b/src/http/modules/ngx_http_userid_filter.c @@ -196,25 +196,22 @@ static ngx_int_t ngx_http_userid_get_uid(ngx_http_request_t *r, ngx_http_userid_ctx_t *ctx, ngx_http_userid_conf_t *conf) { - u_char *start, *last, *end; - ngx_uint_t *cookies, i; - ngx_str_t src, dst; - ngx_table_elt_t *headers; + u_char *start, *last, *end; + ngx_uint_t i; + ngx_str_t src, dst; + ngx_table_elt_t **cookies; - headers = r->headers_in.headers.elts; cookies = r->headers_in.cookies.elts; for (i = 0; i < r->headers_in.cookies.nelts; i++) { - ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "cookie: %d:\"%s\"", - cookies[i], - headers[cookies[i]].value.data); + ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "cookie: \"%s\"", cookies[i]->value.data); - end = headers[cookies[i]].value.data + headers[cookies[i]].value.len; + end = cookies[i]->value.data + cookies[i]->value.len; - for (start = headers[cookies[i]].value.data; start < end; /* void */) { + for (start = cookies[i]->value.data; start < end; /* void */) { - if (conf->name.len >= headers[cookies[i]].value.len + if (conf->name.len >= cookies[i]->value.len || ngx_strncmp(start, conf->name.data, conf->name.len) != 0) { start += conf->name.len; @@ -241,7 +238,7 @@ static ngx_int_t ngx_http_userid_get_uid(ngx_http_request_t *r, if (last - start < 22) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "client sent too short userid cookie \"%s\"", - headers[cookies[i]].value.data); + cookies[i]->value.data); break; } @@ -258,7 +255,7 @@ static ngx_int_t ngx_http_userid_get_uid(ngx_http_request_t *r, if (ngx_decode_base64(&src, &dst) == NGX_ERROR) { ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, "client sent invalid userid cookie \"%s\"", - headers[cookies[i]].value.data); + cookies[i]->value.data); break; } @@ -384,8 +381,7 @@ static ngx_int_t ngx_http_userid_set_uid(ngx_http_request_t *r, ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "uid cookie: \"%s\"", cookie); - set_cookie = ngx_http_add_header(&r->headers_out, ngx_http_headers_out); - if (set_cookie == NULL) { + if (!(set_cookie = ngx_push_list(&r->headers_out.headers))) { return NGX_ERROR; } diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c index 8ac6d506a..5930ceb14 100644 --- a/src/http/modules/proxy/ngx_http_proxy_upstream.c +++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c @@ -113,6 +113,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) ngx_uint_t i; ngx_buf_t *b; ngx_chain_t *chain; + ngx_list_part_t *part; ngx_table_elt_t *header; ngx_http_request_t *r; ngx_http_proxy_upstream_conf_t *uc; @@ -165,8 +166,20 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) } - header = r->headers_in.headers.elts; - for (i = 0; i < r->headers_in.headers.nelts; i++) { + part = &r->headers_in.headers.part; + header = part->elts; + + for (i = 0; /* void */; i++) { + + if (i >= part->nelts) { + if (part->next == NULL) { + break; + } + + part = part->next; + header = part->elts; + i = 0; + } if (&header[i] == r->headers_in.host) { continue; @@ -274,7 +287,20 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p) } - for (i = 0; i < r->headers_in.headers.nelts; i++) { + part = &r->headers_in.headers.part; + header = part->elts; + + for (i = 0; /* void */; i++) { + + if (i >= part->nelts) { + if (part->next == NULL) { + break; + } + + part = part->next; + header = part->elts; + i = 0; + } if (&header[i] == r->headers_in.host) { continue; |