summaryrefslogtreecommitdiffhomepage
path: root/src/http/modules
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2002-12-26 16:26:23 +0000
committerIgor Sysoev <igor@sysoev.ru>2002-12-26 16:26:23 +0000
commit207ed5a589055899a5841d1a9f3074fc4ff407c5 (patch)
tree69cb0a8bafe1997089f3faba616fd6f3f3abe50a /src/http/modules
parent960ffa42cb161b3769cde9bbf2212092e751dfab (diff)
downloadnginx-207ed5a589055899a5841d1a9f3074fc4ff407c5.tar.gz
nginx-207ed5a589055899a5841d1a9f3074fc4ff407c5.tar.bz2
nginx-0.0.1-2002-12-26-19:26:23 import
Diffstat (limited to 'src/http/modules')
-rw-r--r--src/http/modules/ngx_http_event_proxy_handler.c19
-rw-r--r--src/http/modules/ngx_http_index_handler.c71
-rw-r--r--src/http/modules/ngx_http_index_handler.h3
3 files changed, 59 insertions, 34 deletions
diff --git a/src/http/modules/ngx_http_event_proxy_handler.c b/src/http/modules/ngx_http_event_proxy_handler.c
index d7d61785f..9c2cc3ade 100644
--- a/src/http/modules/ngx_http_event_proxy_handler.c
+++ b/src/http/modules/ngx_http_event_proxy_handler.c
@@ -8,7 +8,7 @@
#include <ngx_http.h>
#include <ngx_http_event_proxy_handler.h>
-ngx_http_module_t ngx_http_proxy_module;
+ngx_http_module_t ngx_http_proxy_module_ctx;
static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_request_t *r);
@@ -36,10 +36,11 @@ int ngx_http_proxy_handler(ngx_http_request_t *r)
ngx_chain_t *chain;
ngx_http_proxy_ctx_t *p;
- p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module);
+ p = (ngx_http_proxy_ctx_t *)
+ ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx);
if (p == NULL)
- ngx_http_create_ctx(r, p, ngx_http_proxy_module,
+ ngx_http_create_ctx(r, p, ngx_http_proxy_module_ctx,
sizeof(ngx_http_proxy_ctx_t));
chain = ngx_http_proxy_create_request(r);
@@ -244,7 +245,8 @@ static int ngx_http_proxy_send_request(ngx_event_t *ev)
c = (ngx_connection_t *) ev->data;
r = (ngx_http_request_t *) c->data;
- p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module);
+ p = (ngx_http_proxy_ctx_t *)
+ ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx);
chain = ngx_event_write(c, p->out, 0);
if (chain == (ngx_chain_t *) -1)
@@ -269,7 +271,8 @@ static int ngx_http_proxy_read_response_header(ngx_event_t *ev)
c = (ngx_connection_t *) ev->data;
r = (ngx_http_request_t *) c->data;
- p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module);
+ p = (ngx_http_proxy_ctx_t *)
+ ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx);
if (p->header_in == NULL) {
ngx_test_null(p->header_in,
@@ -389,7 +392,8 @@ static int ngx_http_proxy_read_response_body(ngx_event_t *ev)
c = (ngx_connection_t *) ev->data;
r = (ngx_http_request_t *) c->data;
- p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module);
+ p = (ngx_http_proxy_ctx_t *)
+ ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx);
left = 0;
@@ -464,7 +468,8 @@ static int ngx_http_proxy_write_to_client(ngx_event_t *ev)
c = (ngx_connection_t *) ev->data;
r = (ngx_http_request_t *) c->data;
- p = (ngx_http_proxy_ctx_t *) ngx_get_module_ctx(r, ngx_http_proxy_module);
+ p = (ngx_http_proxy_ctx_t *)
+ ngx_http_get_module_ctx(r, ngx_http_proxy_module_ctx);
do {
h = ((ngx_hunk_t **) p->hunks->elts)[p->hunk_n];
diff --git a/src/http/modules/ngx_http_index_handler.c b/src/http/modules/ngx_http_index_handler.c
index d2084f057..65a896c99 100644
--- a/src/http/modules/ngx_http_index_handler.c
+++ b/src/http/modules/ngx_http_index_handler.c
@@ -13,32 +13,43 @@
static void *ngx_http_index_create_conf(ngx_pool_t *pool);
static void *ngx_http_index_merge_conf(ngx_pool_t *p,
void *parent, void *child);
-static char *ngx_http_index_set_index(ngx_pool_t *p, void *conf,
- ngx_str_t *value);
+static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
+ char *conf);
static ngx_command_t ngx_http_index_commands[] = {
- {"index", ngx_http_index_set_index, 0,
- NGX_HTTP_LOC_CONF, NGX_CONF_ITERATE,
- "set index files"},
-
- {NULL}
+ {ngx_string("index"),
+ NGX_CONF_ANY,
+ ngx_http_index_set_index,
+ NGX_HTTP_LOC_CONF,
+ 0},
+ {ngx_string(""), 0, NULL, 0, 0}
};
-ngx_http_module_t ngx_http_index_module = {
+ngx_http_module_t ngx_http_index_module_ctx = {
NGX_HTTP_MODULE,
NULL, /* create server config */
ngx_http_index_create_conf, /* create location config */
- ngx_http_index_commands, /* module directives */
- NULL, /* init module */
NULL, /* translate handler */
- NULL, /* init output body filter */
+ NULL, /* output header filter */
+ NULL, /* next output header filter */
+ NULL, /* output body filter */
+ NULL, /* next output body filter */
+
+};
+
+
+ngx_module_t ngx_http_index_module = {
+ &ngx_http_index_module_ctx, /* module context */
+ ngx_http_index_commands, /* module directives */
+ NGX_HTTP_MODULE_TYPE, /* module type */
+ NULL /* init module */
};
@@ -53,7 +64,7 @@ int ngx_http_index_handler(ngx_http_request_t *r)
ngx_http_index_conf_t *cf;
cf = (ngx_http_index_conf_t *)
- ngx_get_module_loc_conf(r, ngx_http_index_module);
+ ngx_http_get_module_loc_conf(r, ngx_http_index_module_ctx);
ngx_test_null(name,
ngx_palloc(r->pool,
@@ -71,11 +82,13 @@ int ngx_http_index_handler(ngx_http_request_t *r)
fd = ngx_open_file(name, NGX_FILE_RDONLY);
if (fd == NGX_INVALID_FILE) {
err = ngx_errno;
- if (err == NGX_ENOENT)
+ if (err == NGX_ENOENT) {
continue;
+ }
#if (WIN32)
- if (err == ERROR_PATH_NOT_FOUND)
+ if (err == ERROR_PATH_NOT_FOUND) {
continue;
+ }
#endif
ngx_log_error(NGX_LOG_ERR, r->connection->log, err,
@@ -117,8 +130,9 @@ static void *ngx_http_index_merge_conf(ngx_pool_t *p, void *parent, void *child)
ngx_str_t *index;
if (conf->max_index_len == 0) {
- if (prev->max_index_len != 0)
+ if (prev->max_index_len != 0) {
return prev;
+ }
ngx_test_null(index, ngx_push_array(conf->indices), NULL);
index->len = sizeof(NGX_HTTP_INDEX) - 1;
@@ -130,18 +144,23 @@ static void *ngx_http_index_merge_conf(ngx_pool_t *p, void *parent, void *child)
}
-static char *ngx_http_index_set_index(ngx_pool_t *p, void *conf,
- ngx_str_t *value)
+static char *ngx_http_index_set_index(ngx_conf_t *cf, ngx_command_t *cmd,
+ char *conf)
{
- ngx_http_index_conf_t *cf = (ngx_http_index_conf_t *) conf;
- ngx_str_t *index;
-
- ngx_test_null(index, ngx_push_array(cf->indices), NULL);
- index->len = value->len;
- index->data = value->data;
-
- if (cf->max_index_len < index->len)
- cf->max_index_len = index->len;
+ ngx_http_index_conf_t *icf = (ngx_http_index_conf_t *) conf;
+ int i;
+ ngx_str_t *index, *value;
+
+ value = (ngx_str_t *) cf->args->elts;
+ for (i = 1; i < cf->args->nelts; i++) {
+ ngx_test_null(index, ngx_push_array(icf->indices), NULL);
+ index->len = value[i].len;
+ index->data = value[i].data;
+
+ if (icf->max_index_len < index->len) {
+ icf->max_index_len = index->len;
+ }
+ }
return NULL;
}
diff --git a/src/http/modules/ngx_http_index_handler.h b/src/http/modules/ngx_http_index_handler.h
index 66261b0bc..3dd6bd82c 100644
--- a/src/http/modules/ngx_http_index_handler.h
+++ b/src/http/modules/ngx_http_index_handler.h
@@ -9,13 +9,14 @@
#define NGX_HTTP_INDEX "index.html"
+
typedef struct {
ngx_array_t *indices;
size_t max_index_len;
} ngx_http_index_conf_t;
-extern ngx_http_module_t ngx_http_index_module;
+extern ngx_module_t ngx_http_index_module;
#endif /* _NGX_HTTP_INDEX_HANDLER_H_INCLUDED_ */