nginx-0.0.1-2003-04-28-19:06:39 import
diff --git a/src/http/modules/proxy/ngx_http_event_proxy_handler.c b/src/http/modules/proxy/ngx_http_event_proxy_handler.c
index 26ccf4f..9b1ddc4 100644
--- a/src/http/modules/proxy/ngx_http_event_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_event_proxy_handler.c
@@ -902,9 +902,6 @@
ep->temp_file->fd = NGX_INVALID_FILE;
ep->temp_file->log = p->log;
- ep->number = 10;
- ep->random = 5;
-
ep->max_temp_file_size = p->lcf->max_temp_file_size;
ep->temp_file_write_size = p->lcf->temp_file_write_size;
ep->temp_file_warn = "an upstream response is buffered "
@@ -1396,7 +1393,7 @@
path.len += path.level[i] + 1;
}
- return ngx_create_temp_file(&file, &path, pool, 123456789, 2, 0);
+ return ngx_create_temp_file(&file, &path, pool, 0);
}
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index 8bb2cc1..906eb29 100644
--- a/src/http/ngx_http.h
+++ b/src/http/ngx_http.h
@@ -86,6 +86,18 @@
typedef struct {
+ ngx_chain_t chain[4];
+ ngx_hunk_t *header_out;
+ ngx_hunk_t *hunk;
+ ngx_hunk_t *file_hunk;
+ ngx_file_t temp_file;
+ ngx_path_t *temp_path;
+ off_t offset;
+ char *header_in_pos;
+} ngx_http_request_body_t;
+
+
+typedef struct {
int status;
ngx_str_t status_line;
@@ -116,11 +128,12 @@
ngx_file_t file;
- ngx_pool_t *pool;
- ngx_hunk_t *header_in;
+ ngx_pool_t *pool;
+ ngx_hunk_t *header_in;
+ ngx_http_request_body_t *request_body;
- ngx_http_headers_in_t headers_in;
- ngx_http_headers_out_t headers_out;
+ ngx_http_headers_in_t headers_in;
+ ngx_http_headers_out_t headers_out;
int (*handler)(ngx_http_request_t *r);
@@ -224,6 +237,12 @@
int ngx_http_handler(ngx_http_request_t *r);
+int ngx_http_init_client_request_body(ngx_http_request_t *r, int size);
+int ngx_http_read_client_request_body(ngx_http_request_t *r);
+int ngx_http_init_client_request_body_chain(ngx_http_request_t *r);
+void ngx_http_reinit_client_request_body_hunks(ngx_http_request_t *r);
+
+
int ngx_http_send_header(ngx_http_request_t *r);
int ngx_http_special_response_handler(ngx_http_request_t *r, int error);
diff --git a/src/http/ngx_http_output_filter.c b/src/http/ngx_http_output_filter.c
index 485aae3..2a7ada7 100644
--- a/src/http/ngx_http_output_filter.c
+++ b/src/http/ngx_http_output_filter.c
@@ -26,9 +26,10 @@
NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET,
- offsetof(ngx_http_output_filter_conf_t, hunk_size)},
+ offsetof(ngx_http_output_filter_conf_t, hunk_size),
+ NULL},
- {ngx_null_string, 0, NULL, 0, 0}
+ {ngx_null_string, 0, NULL, 0, 0, NULL}
};
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
index b21331e..b954066 100644
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -1,56 +1,55 @@
+#include <ngx_config.h>
+#include <ngx_core.h>
+#include <ngx_http.h>
-
-int ngx_http_start_read_client_body(ngx_http_proxy_ctx_t *p)
+int ngx_http_init_client_request_body(ngx_http_request_t *r, int size)
{
- int first_part, size;
- ngx_hunk_t *h;
- ngx_http_request_t *r;
+ int header_in_part, len;
+ ngx_hunk_t *h;
+ ngx_http_request_body_t *rb;
- r = p->request;
+ ngx_test_null(rb, ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t)),
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
- first_part = r->header_in->last - r->header_in->pos;
+ header_in_part = r->header_in->end - r->header_in->pos;
- if (first_part > r->headers_in.content_length_n) {
- first_part = r->headers_in.content_length_n;
- size = 0;
+ if (header_in_part) {
+ rb->header_in_pos = r->header_in->pos;
+ }
+
+ if (header_in_part > r->headers_in.content_length_n) {
+ header_in_part = r->headers_in.content_length_n;
} else {
- size = r->headers_in.content_length_n - first_part;
- if (size > p->lcf->client_request_buffer_size) {
- size = p->lcf->client_request_buffer_size;
+ len = r->headers_in.content_length_n - header_in_part;
+ if (len > size) {
+ len = size;
- } else if (size > NGX_PAGE_SIZE) {
- size = ((size + NGX_PAGE_SIZE) / NGX_PAGE_SIZE) * NGX_PAGE_SIZE;
+ } else if (len > NGX_PAGE_SIZE) {
+ len = ((len + NGX_PAGE_SIZE - 1) / NGX_PAGE_SIZE) * NGX_PAGE_SIZE;
}
- if (size) {
- ngx_test_null(p->client_request_hunk, ngx_palloc(r->pool, size),
- NGX_ERROR);
+ if (len) {
+ ngx_test_null(rb->hunk, ngx_create_temp_hunk(r->pool, len, 0, 0),
+ NGX_HTTP_INTERNAL_SERVER_ERROR);
}
}
- if (first_part) {
- ngx_test_null(h, ngx_alloc_hunk(r->pool), NGX_ERROR);
-
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
- h->pos = h->start = h->pre_start = r->header_in->pos;
- h->last = h->end = h->post_end = r->header_in->pos + first_part;
- h->file_pos = h->file_last = 0;
- h->file = NULL;
- h->shadow = NULL;
- h->tag = 0;
-
- p->client_first_part_hunk = h;
- }
+ r->request_body = rb;
return NGX_OK;
}
-int ngx_http_read_client_body(ngx_event_t *rev)
+int ngx_http_read_client_request_body(ngx_http_request_t *r)
{
+ int size, n, rc;
+ ngx_chain_t *entry;
+ ngx_http_request_body_t *rb;
+
+ rb = r->request_body;
do {
if (r->header_in->last < r->header_in->end) {
@@ -70,7 +69,7 @@
rb->chain[0].next = NULL;
}
- n = ngx_recv_chain(c, &rb->chain);
+ n = ngx_recv_chain(r->connection, rb->chain);
if (n == NGX_ERROR) {
return NGX_ERROR;
@@ -80,7 +79,7 @@
return NGX_AGAIN;
}
- for (entry = &rb->chain; entry; entry = entry->next) {
+ for (entry = rb->chain; entry; entry = entry->next) {
size = entry->hunk->end - entry->hunk->last;
if (n >= size) {
@@ -96,9 +95,9 @@
}
if (rb->hunk && rb->hunk->last == rb->hunk->end) {
- if (rb->temp_file->fd == NGX_INVALID_FILE) {
- rc = ngx_create_temp_file(rb->temp_file, rb->temp_path, r->pool,
- rb->number, rb->random, 0);
+ if (rb->temp_file.fd == NGX_INVALID_FILE) {
+ rc = ngx_create_temp_file(&rb->temp_file, rb->temp_path,
+ r->pool, 0);
if (rc == NGX_ERROR) {
return NGX_ERROR;
@@ -109,7 +108,7 @@
}
}
- n = ngx_write_file(rb->temp_file, rb->hunk,
+ n = ngx_write_file(&rb->temp_file, rb->hunk->pos,
rb->hunk->last - rb->hunk->pos, rb->offset);
if (rc == NGX_ERROR) {
@@ -120,13 +119,13 @@
rb->hunk->last = rb->hunk->pos;
}
- } while (rev->ready);
+ } while (r->connection->read->ready);
return NGX_OK;
}
-int ngx_init_client_request_body_chain(ngx_http_reuqest_t *r)
+int ngx_http_init_client_request_body_chain(ngx_http_request_t *r)
{
int i;
ngx_hunk_t *h;
@@ -143,7 +142,8 @@
rb->chain[i].hunk = r->header_in;
}
- if (rb->temp_file->fd != NGX_INVALID_FILE) {
+ if (rb->temp_file.fd != NGX_INVALID_FILE) {
+
if (rb->file_hunk == NULL) {
ngx_test_null(h, ngx_alloc_hunk(r->pool), NGX_ERROR);
@@ -152,7 +152,7 @@
h->last = h->end = h->post_end = 0;
h->file_pos = 0;
h->file_last = rb->offset;
- h->file = rb->temp_file;
+ h->file = &rb->temp_file;
h->shadow = NULL;
h->tag = 0;
@@ -176,7 +176,7 @@
}
-int ngx_reinit_client_request_body_hunks(ngx_http_reuqest_t *r)
+void ngx_http_reinit_client_request_body_hunks(ngx_http_request_t *r)
{
ngx_http_request_body_t *rb;
@@ -187,7 +187,7 @@
}
if (rb->file_hunk) {
- rb->file_hunk->file_pos = rb->file_hunk->file_start;
+ rb->file_hunk->file_pos = 0;
}
if (rb->hunk) {
diff --git a/src/http/ngx_http_write_filter.c b/src/http/ngx_http_write_filter.c
index 4d7b958..752a932 100644
--- a/src/http/ngx_http_write_filter.c
+++ b/src/http/ngx_http_write_filter.c
@@ -25,9 +25,10 @@
NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_size_slot,
NGX_HTTP_LOC_CONF_OFFSET,
- offsetof(ngx_http_write_filter_conf_t, buffer_output)},
+ offsetof(ngx_http_write_filter_conf_t, buffer_output),
+ NULL},
- {ngx_null_string, 0, NULL, 0, 0}
+ {ngx_null_string, 0, NULL, 0, 0, NULL}
};