nginx-0.0.3-2004-05-18-19:29:08 import
diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c
index fc4c950..bb05b72 100644
--- a/src/core/ngx_conf_file.c
+++ b/src/core/ngx_conf_file.c
@@ -3,7 +3,34 @@
#include <ngx_core.h>
-/* Ten fixed arguments */
+static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
+
+
+static ngx_command_t ngx_conf_commands[] = {
+
+ { ngx_string("include"),
+ NGX_ANY_CONF|NGX_CONF_TAKE1,
+ ngx_conf_include,
+ 0,
+ 0,
+ NULL },
+
+ ngx_null_command
+};
+
+
+ngx_module_t ngx_conf_module = {
+ NGX_MODULE,
+ NULL, /* module context */
+ ngx_conf_commands, /* module directives */
+ NGX_CONF_MODULE, /* module type */
+ NULL, /* init module */
+ NULL /* init child */
+};
+
+
+
+/* The ten fixed arguments */
static int argument_number[] = {
NGX_CONF_NOARGS,
@@ -513,6 +540,27 @@
}
+static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ ngx_str_t *value, file;
+
+ value = cf->args->elts;
+
+ file.len = cf->cycle->root.len + value[1].len;
+ if (!(file.data = ngx_palloc(cf->pool, file.len + 1))) {
+ return NGX_CONF_ERROR;
+ }
+
+ ngx_cpystrn(ngx_cpymem(file.data, cf->cycle->root.data,
+ cf->cycle->root.len),
+ value[1].data, value[1].len + 1);
+
+ ngx_log_error(NGX_LOG_INFO, cf->log, 0, "include %s", file.data);
+
+ return ngx_conf_parse(cf, &file);
+}
+
+
ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name)
{
ngx_uint_t i;
diff --git a/src/core/ngx_conf_file.h b/src/core/ngx_conf_file.h
index 01080cc..ff01e88 100644
--- a/src/core/ngx_conf_file.h
+++ b/src/core/ngx_conf_file.h
@@ -37,7 +37,9 @@
#define NGX_CONF_2MORE 0x00001000
#define NGX_DIRECT_CONF 0x00010000
+
#define NGX_MAIN_CONF 0x01000000
+#define NGX_ANY_CONF 0x0F000000
diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c
index 24e30f7..989973a 100644
--- a/src/core/ngx_cycle.c
+++ b/src/core/ngx_cycle.c
@@ -24,6 +24,7 @@
ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle)
{
void *rv;
+ u_char *root;
ngx_uint_t i, n, failed;
ngx_log_t *log;
ngx_conf_t conf;
@@ -33,6 +34,7 @@
ngx_open_file_t *file;
ngx_listening_t *ls, *nls;
ngx_core_module_t *module;
+ char cwd[NGX_MAX_PATH + 1];
log = old_cycle->log;
@@ -51,6 +53,42 @@
cycle->conf_file = old_cycle->conf_file;
+ for (i = cycle->conf_file.len; i > 0; i--) {
+ if (cycle->conf_file.data[i] == '/') {
+ break;
+ }
+ }
+
+ if (i == 0 && cycle->conf_file.data[i] != '/') {
+ if (ngx_getcwd(cwd, NGX_MAX_PATH) == 0) {
+ ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
+ ngx_getcwd_n " failed");
+ ngx_destroy_pool(pool);
+ return NULL;
+ }
+
+ for ( /* void */; i < NGX_MAX_PATH && cwd[i]; i++) /* void */;
+ cwd[i] = '/';
+ cwd[i + 1] = '\0';
+
+ root = (u_char *) cwd;
+
+ } else {
+ root = cycle->conf_file.data;
+ }
+
+ cycle->root.len = ++i;
+ cycle->root.data = ngx_palloc(pool, ++i);
+ if (cycle->root.data == NULL) {
+ ngx_destroy_pool(pool);
+ return NULL;
+ }
+
+ ngx_cpystrn(cycle->root.data, root, i);
+
+ ngx_log_error(NGX_LOG_INFO, log, 0, "root: %s", cycle->root.data);
+
+
n = old_cycle->pathes.nelts ? old_cycle->pathes.nelts : 10;
if (!(cycle->pathes.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *)))) {
ngx_destroy_pool(pool);
diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h
index 6588a7a..e1b5368 100644
--- a/src/core/ngx_cycle.h
+++ b/src/core/ngx_cycle.h
@@ -25,6 +25,7 @@
ngx_cycle_t *old_cycle;
ngx_str_t conf_file;
+ ngx_str_t root;
};
diff --git a/src/http/modules/ngx_http_chunked_filter.c b/src/http/modules/ngx_http_chunked_filter.c
index 61eae5d..3cd6ddd 100644
--- a/src/http/modules/ngx_http_chunked_filter.c
+++ b/src/http/modules/ngx_http_chunked_filter.c
@@ -66,12 +66,16 @@
}
ngx_test_null(out, ngx_alloc_chain_link(r->pool), NGX_ERROR);
+ out->hunk = NULL;
ll = &out->next;
size = 0;
cl = in;
for ( ;; ) {
+ ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
+ "http chunk: %d", ngx_hunk_size(cl->hunk));
+
size += ngx_hunk_size(cl->hunk);
ngx_test_null(tl, ngx_alloc_chain_link(r->pool), NGX_ERROR);
@@ -86,25 +90,41 @@
cl = cl->next;
}
- ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR);
- len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size);
+ if (size) {
+ ngx_test_null(chunk, ngx_palloc(r->pool, 11), NGX_ERROR);
+ len = ngx_snprintf((char *) chunk, 11, SIZE_T_X_FMT CRLF, size);
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
- h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
- h->pos = chunk;
- h->last = chunk + len;
+ ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
+ h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
+ h->pos = chunk;
+ h->last = chunk + len;
- out->hunk = h;
-
- ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
+ out->hunk = h;
+ }
if (cl->hunk->type & NGX_HUNK_LAST) {
- cl->hunk->type &= ~NGX_HUNK_LAST;
+
+ ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY|NGX_HUNK_LAST;
h->pos = (u_char *) CRLF "0" CRLF CRLF;
h->last = h->pos + 7;
+ cl->hunk->type &= ~NGX_HUNK_LAST;
+
+ if (size == 0) {
+ out->hunk = h;
+ out->next = NULL;
+
+ return ngx_http_next_body_filter(r, out);
+ }
+
} else {
+ if (size == 0) {
+ *ll = NULL;
+ return ngx_http_next_body_filter(r, out->next);
+ }
+
+ ngx_test_null(h, ngx_calloc_hunk(r->pool), NGX_ERROR);
h->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_MEMORY;
h->pos = (u_char *) CRLF;
h->last = h->pos + 2;
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 8aa3397..d523fc1 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -278,6 +278,7 @@
offsetof(ngx_http_proxy_headers_in_t, location) },
{ ngx_string("Accept-Ranges"),
offsetof(ngx_http_proxy_headers_in_t, accept_ranges) },
+ { ngx_string("X-Pad"), offsetof(ngx_http_proxy_headers_in_t, x_pad) },
{ ngx_null_string, 0 }
};
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.h b/src/http/modules/proxy/ngx_http_proxy_handler.h
index 55eee74..e0f85ee 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.h
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.h
@@ -123,6 +123,7 @@
ngx_table_elt_t *last_modified;
ngx_table_elt_t *location;
ngx_table_elt_t *accept_ranges;
+ ngx_table_elt_t *x_pad;
off_t content_length_n;
} ngx_http_proxy_headers_in_t;
diff --git a/src/http/modules/proxy/ngx_http_proxy_header.c b/src/http/modules/proxy/ngx_http_proxy_header.c
index cb13034..a3e05e5 100644
--- a/src/http/modules/proxy/ngx_http_proxy_header.c
+++ b/src/http/modules/proxy/ngx_http_proxy_header.c
@@ -26,6 +26,10 @@
continue;
}
+ if (&h[i] == headers_in->x_pad) {
+ continue;
+ }
+
if (p->accel) {
if (&h[i] == headers_in->date
|| &h[i] == headers_in->accept_ranges) {
diff --git a/src/os/unix/ngx_files.h b/src/os/unix/ngx_files.h
index 9fe8370..1553144 100644
--- a/src/os/unix/ngx_files.h
+++ b/src/os/unix/ngx_files.h
@@ -63,6 +63,11 @@
#define ngx_file_uniq(sb) (sb)->st_ino
+
+#define ngx_getcwd(buf, size) (getcwd(buf, size) != NULL)
+#define ngx_getcwd_n "getcwd()"
+#define NGX_MAX_PATH PATH_MAX
+
#define NGX_DIR_MASK_LEN 0
diff --git a/src/os/win32/ngx_files.h b/src/os/win32/ngx_files.h
index 6915f97..c59e79d 100644
--- a/src/os/win32/ngx_files.h
+++ b/src/os/win32/ngx_files.h
@@ -94,6 +94,11 @@
- 116444736000000000) / 10000000)
+#define ngx_getcwd(buf, size) GetCurrentDirectory(size, buf)
+#define ngx_getcwd_n "GetCurrentDirectory()"
+#define NGX_MAX_PATH MAX_PATH
+
+
#define NGX_DIR_MASK (u_char *) "/*"
#define NGX_DIR_MASK_LEN 2