diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2003-10-21 16:49:56 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2003-10-21 16:49:56 +0000 |
| commit | 419f9aceb4d994c2f7f51400f59fb2da0ed666d4 (patch) | |
| tree | e32162d1d3833491fc1a95780880099f2ef6857f /src/http/modules | |
| parent | 9760a1336f0eb4057b6e2ccdd4b0145087102b17 (diff) | |
| download | nginx-419f9aceb4d994c2f7f51400f59fb2da0ed666d4.tar.gz nginx-419f9aceb4d994c2f7f51400f59fb2da0ed666d4.tar.bz2 | |
nginx-0.0.1-2003-10-21-20:49:56 import
Diffstat (limited to 'src/http/modules')
| -rw-r--r-- | src/http/modules/ngx_http_chunked_filter.c | 2 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_gzip_filter.c | 5 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_not_modified_filter.c | 3 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_range_filter.c | 22 | ||||
| -rw-r--r-- | src/http/modules/ngx_http_static_handler.c | 8 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.c | 51 | ||||
| -rw-r--r-- | src/http/modules/proxy/ngx_http_proxy_handler.h | 4 |
7 files changed, 55 insertions, 40 deletions
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c index 090c4ce64..83981baf2 100644 --- a/src/http/modules/ngx_http_chunked_filter.c +++ b/src/http/modules/ngx_http_chunked_filter.c @@ -39,7 +39,7 @@ static int ngx_http_chunked_header_filter(ngx_http_request_t *r) return next_header_filter(r); } - if (r->headers_out.content_length == -1) { + if (r->headers_out.content_length_n == -1) { if (r->http_version < NGX_HTTP_VERSION_11) { r->keepalive = 0; diff --git a/src/http/modules/ngx_http_gzip_filter.c b/src/http/modules/ngx_http_gzip_filter.c index f5e83842a..df360b80b 100644 --- a/src/http/modules/ngx_http_gzip_filter.c +++ b/src/http/modules/ngx_http_gzip_filter.c @@ -157,8 +157,9 @@ static int ngx_http_gzip_header_filter(ngx_http_request_t *r) r->headers_out.content_encoding->value.len = 4; r->headers_out.content_encoding->value.data = "gzip"; - ctx->length = r->headers_out.content_length; - r->headers_out.content_length = -1; + ctx->length = r->headers_out.content_length_n; + r->headers_out.content_length_n = -1; + r->headers_out.content_length = NULL; r->filter |= NGX_HTTP_FILTER_NEED_IN_MEMORY; return next_header_filter(r); diff --git a/src/http/modules/ngx_http_not_modified_filter.c b/src/http/modules/ngx_http_not_modified_filter.c index f1ccd4456..3435ed5b6 100644 --- a/src/http/modules/ngx_http_not_modified_filter.c +++ b/src/http/modules/ngx_http_not_modified_filter.c @@ -54,7 +54,8 @@ static int ngx_http_not_modified_header_filter(ngx_http_request_t *r) if (ims != NGX_ERROR && ims == r->headers_out.last_modified_time) { r->headers_out.status = NGX_HTTP_NOT_MODIFIED; - r->headers_out.content_length = -1; + r->headers_out.content_length_n = -1; + r->headers_out.content_length = NULL; r->headers_out.content_type->key.len = 0; r->headers_out.content_type = NULL; r->headers_out.accept_ranges->key.len = 0; diff --git a/src/http/modules/ngx_http_range_filter.c b/src/http/modules/ngx_http_range_filter.c index 8344aa630..c51a5f0cb 100644 --- a/src/http/modules/ngx_http_range_filter.c +++ b/src/http/modules/ngx_http_range_filter.c @@ -49,7 +49,7 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) if (r->main || r->http_version < NGX_HTTP_VERSION_10 || r->headers_out.status != NGX_HTTP_OK - || r->headers_out.content_length == -1 + || r->headers_out.content_length_n == -1 /* STUB: we currently support ranges for file hunks only */ || r->filter & NGX_HTTP_FILTER_NEED_IN_MEMORY) { @@ -103,7 +103,7 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) break; } - if (start >= r->headers_out.content_length) { + if (start >= r->headers_out.content_length_n) { rc = NGX_HTTP_RANGE_NOT_SATISFIABLE; break; } @@ -114,7 +114,7 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) ngx_test_null(range, ngx_push_array(&r->headers_out.ranges), NGX_ERROR); range->start = start; - range->end = r->headers_out.content_length; + range->end = r->headers_out.content_length_n; if (*p++ == ',') { continue; @@ -139,7 +139,7 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) break; } - if (end >= r->headers_out.content_length || start >= end) { + if (end >= r->headers_out.content_length_n || start >= end) { rc = NGX_HTTP_RANGE_NOT_SATISFIABLE; break; } @@ -170,9 +170,10 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) r->headers_out.content_range->value.len = ngx_snprintf(r->headers_out.content_range->value.data, 8 + 20 + 1, "bytes */" OFF_FMT, - r->headers_out.content_length); + r->headers_out.content_length_n); - r->headers_out.content_length = -1; + r->headers_out.content_length_n = -1; + r->headers_out.content_length = NULL; return rc; @@ -193,9 +194,9 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) 6 + 20 + 1 + 20 + 1 + 20 + 1, "bytes " OFF_FMT "-" OFF_FMT "/" OFF_FMT, range->start, range->end - 1, - r->headers_out.content_length); + r->headers_out.content_length_n); - r->headers_out.content_length = range->end - range->start; + r->headers_out.content_length_n = range->end - range->start; } else { @@ -267,13 +268,14 @@ static int ngx_http_range_header_filter(ngx_http_request_t *r) 20 + 1 + 20 + 1 + 20 + 5, OFF_FMT "-" OFF_FMT "/" OFF_FMT CRLF CRLF, range[i].start, range[i].end - 1, - r->headers_out.content_length); + r->headers_out.content_length_n); len += ctx->boundary_header.len + range[i].content_range.len + (size_t) (range[i].end - range[i].start); } - r->headers_out.content_length = len; + r->headers_out.content_length_n = len; + r->headers_out.content_length = NULL; } } diff --git a/src/http/modules/ngx_http_static_handler.c b/src/http/modules/ngx_http_static_handler.c index 8b414d76d..f4955ef3d 100644 --- a/src/http/modules/ngx_http_static_handler.c +++ b/src/http/modules/ngx_http_static_handler.c @@ -191,6 +191,7 @@ static int ngx_http_static_handler(ngx_http_request_t *r) ngx_log_e level; ngx_err_t err; ngx_hunk_t *h; + ngx_chain_t out; ngx_http_type_t *type; ngx_http_log_ctx_t *ctx; ngx_http_core_loc_conf_t *clcf; @@ -257,7 +258,7 @@ static int ngx_http_static_handler(ngx_http_request_t *r) #endif r->headers_out.status = NGX_HTTP_OK; - r->headers_out.content_length = ngx_file_size(r->file.info); + r->headers_out.content_length_n = ngx_file_size(r->file.info); r->headers_out.last_modified_time = ngx_file_mtime(r->file.info); ngx_test_null(r->headers_out.content_type, @@ -317,7 +318,10 @@ static int ngx_http_static_handler(ngx_http_request_t *r) h->file->fd = r->file.fd; h->file->log = r->connection->log; - return ngx_http_output_filter(r, h); + out.hunk = h; + out.next = NULL; + + return ngx_http_output_filter(r, &out); } diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c index 16a9ed4bd..eefa1f886 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.c +++ b/src/http/modules/proxy/ngx_http_proxy_handler.c @@ -2,8 +2,8 @@ #include <ngx_config.h> #include <ngx_core.h> #include <ngx_event.h> -/* STUB */ #include <ngx_event_connect.h> -/* STUB */ #include <ngx_event_proxy.h> +#include <ngx_event_connect.h> +#include <ngx_event_pipe.h> #include <ngx_http.h> #include <ngx_http_proxy_handler.h> @@ -632,12 +632,13 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) { int rc, i; ngx_table_elt_t *ch, *ph; - ngx_event_proxy_t *ep; + ngx_event_pipe_t *ep; ngx_http_request_t *r; r = p->request; - r->headers_out.content_length = -1; + r->headers_out.content_length_n = -1; + r->headers_out.content_length = NULL; /* copy an upstream header to r->headers_out */ @@ -655,13 +656,6 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) } } - if (&ph[i] == p->headers_in.content_length) { - r->headers_out.content_length = - ngx_atoi(p->headers_in.content_length->value.data, - p->headers_in.content_length->value.len); - continue; - } - ch = ngx_push_table(r->headers_out.headers); if (ch == NULL) { ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR); @@ -675,6 +669,14 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) r->headers_out.content_type->key.len = 0; continue; } + + if (&ph[i] == p->headers_in.content_length) { + r->headers_out.content_length_n = + ngx_atoi(p->headers_in.content_length->value.data, + p->headers_in.content_length->value.len); + r->headers_out.content_length = ch; + continue; + } } /* STUB */ @@ -700,14 +702,14 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) p->header_sent = 1; - ep = ngx_pcalloc(r->pool, sizeof(ngx_event_proxy_t)); + ep = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t)); if (ep == NULL) { ngx_http_proxy_finalize_request(p, 0); return; } - ep->input_filter = ngx_event_proxy_copy_input_filter; - ep->output_filter = (ngx_event_proxy_output_filter_pt) + ep->input_filter = ngx_event_pipe_copy_input_filter; + ep->output_filter = (ngx_event_pipe_output_filter_pt) ngx_http_output_filter; ep->output_ctx = r; ep->bufs = p->lcf->bufs; @@ -743,14 +745,17 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p) ep->preread_size = p->header_in->last - p->header_in->pos; /* - * event_proxy would do p->header_in->last += ep->preread_size - * as these bytes were read. + * event_pipe would do p->header_in->last += ep->preread_size + * as though these bytes were read. */ p->header_in->last = p->header_in->pos; - /* STUB */ ep->cachable = 0; + /* STUB */ ep->cachable = 1; +#if 0 + ep->max_temp_file_size = 1000000000; +#endif - p->event_proxy = ep; + p->event_pipe = ep; #if 0 lcx = p->log->data; @@ -771,7 +776,7 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev) ngx_connection_t *c; ngx_http_request_t *r; ngx_http_proxy_ctx_t *p; - ngx_event_proxy_t *ep; + ngx_event_pipe_t *ep; c = ev->data; @@ -786,7 +791,7 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev) r = p->request; } - ep = p->event_proxy; + ep = p->event_pipe; if (ev->timedout) { if (ev->write) { @@ -797,7 +802,7 @@ static void ngx_http_proxy_process_body(ngx_event_t *ev) } } else { - if (ngx_event_proxy(ep, ev->write) == NGX_ABORT) { + if (ngx_event_pipe(ep, ev->write) == NGX_ABORT) { ngx_http_proxy_finalize_request(p, 0); return; } @@ -1159,14 +1164,14 @@ static void *ngx_http_proxy_create_loc_conf(ngx_conf_t *cf) conf->bufs.num = 10; conf->bufs.size = 4096; - conf->max_busy_len = 8192 + 4096; + conf->max_busy_len = 8192; /* CHECK in _init conf->max_temp_size >= conf->bufs.size !!! */ conf->max_temp_file_size = 4096 * 6; - conf->temp_file_write_size = 4096 * 2; + conf->temp_file_write_size = 4096 * 1; ngx_test_null(conf->temp_path, ngx_pcalloc(cf->pool, sizeof(ngx_path_t)), NULL); diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h index 207b6480e..fe6ca23b7 100644 --- a/src/http/modules/proxy/ngx_http_proxy_handler.h +++ b/src/http/modules/proxy/ngx_http_proxy_handler.h @@ -48,6 +48,8 @@ typedef struct { ngx_table_elt_t *last_modified; ngx_table_elt_t *accept_ranges; + off_t content_length_n; + ngx_table_t *headers; } ngx_http_proxy_headers_in_t; @@ -74,7 +76,7 @@ struct ngx_http_proxy_ctx_s { int location_len; ngx_str_t host_header; - ngx_event_proxy_t *event_proxy; + ngx_event_pipe_t *event_pipe; unsigned accel:1; unsigned cachable:1; |
