2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) Igor Sysoev
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <ngx_config.h>
|
|
|
|
#include <ngx_core.h>
|
|
|
|
#include <ngx_http.h>
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ngx_buf_t *buf;
|
|
|
|
size_t size;
|
|
|
|
ngx_pool_t *pool;
|
|
|
|
size_t alloc_size;
|
|
|
|
ngx_chain_t **last_out;
|
|
|
|
} ngx_http_autoindex_ctx_t;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ngx_str_t name;
|
2005-06-23 21:41:06 +08:00
|
|
|
size_t utf_len;
|
2009-05-18 03:01:23 +08:00
|
|
|
size_t escape;
|
|
|
|
|
|
|
|
unsigned dir:1;
|
|
|
|
unsigned colon:1;
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
time_t mtime;
|
|
|
|
off_t size;
|
|
|
|
} ngx_http_autoindex_entry_t;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ngx_flag_t enable;
|
2005-05-27 02:12:40 +08:00
|
|
|
ngx_flag_t localtime;
|
2005-07-08 22:34:20 +08:00
|
|
|
ngx_flag_t exact_size;
|
2004-10-25 23:29:23 +08:00
|
|
|
} ngx_http_autoindex_loc_conf_t;
|
|
|
|
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
#define NGX_HTTP_AUTOINDEX_PREALLOCATE 50
|
|
|
|
|
|
|
|
#define NGX_HTTP_AUTOINDEX_NAME_LEN 50
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
|
2005-03-23 00:02:46 +08:00
|
|
|
static int ngx_libc_cdecl ngx_http_autoindex_cmp_entries(const void *one,
|
|
|
|
const void *two);
|
2005-03-04 22:06:57 +08:00
|
|
|
static ngx_int_t ngx_http_autoindex_error(ngx_http_request_t *r,
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_dir_t *dir, ngx_str_t *name);
|
2006-08-30 18:39:17 +08:00
|
|
|
static ngx_int_t ngx_http_autoindex_init(ngx_conf_t *cf);
|
2004-10-25 23:29:23 +08:00
|
|
|
static void *ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf);
|
|
|
|
static char *ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf,
|
2005-03-04 22:06:57 +08:00
|
|
|
void *parent, void *child);
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
static ngx_command_t ngx_http_autoindex_commands[] = {
|
|
|
|
|
|
|
|
{ ngx_string("autoindex"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
|
|
ngx_conf_set_flag_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_autoindex_loc_conf_t, enable),
|
|
|
|
NULL },
|
|
|
|
|
2005-05-27 02:12:40 +08:00
|
|
|
{ ngx_string("autoindex_localtime"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
|
|
ngx_conf_set_flag_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_autoindex_loc_conf_t, localtime),
|
|
|
|
NULL },
|
|
|
|
|
2005-07-08 22:34:20 +08:00
|
|
|
{ ngx_string("autoindex_exact_size"),
|
|
|
|
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
|
|
|
|
ngx_conf_set_flag_slot,
|
|
|
|
NGX_HTTP_LOC_CONF_OFFSET,
|
|
|
|
offsetof(ngx_http_autoindex_loc_conf_t, exact_size),
|
|
|
|
NULL },
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
ngx_null_command
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-07-28 23:16:17 +08:00
|
|
|
static ngx_http_module_t ngx_http_autoindex_module_ctx = {
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
NULL, /* preconfiguration */
|
2006-08-30 18:39:17 +08:00
|
|
|
ngx_http_autoindex_init, /* postconfiguration */
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
NULL, /* create main configuration */
|
|
|
|
NULL, /* init main configuration */
|
|
|
|
|
|
|
|
NULL, /* create server configuration */
|
|
|
|
NULL, /* merge server configuration */
|
|
|
|
|
|
|
|
ngx_http_autoindex_create_loc_conf, /* create location configration */
|
|
|
|
ngx_http_autoindex_merge_loc_conf /* merge location configration */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
ngx_module_t ngx_http_autoindex_module = {
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
NGX_MODULE_V1,
|
2005-11-15 21:30:52 +08:00
|
|
|
&ngx_http_autoindex_module_ctx, /* module context */
|
2004-10-25 23:29:23 +08:00
|
|
|
ngx_http_autoindex_commands, /* module directives */
|
|
|
|
NGX_HTTP_MODULE, /* module type */
|
2005-09-08 22:36:09 +08:00
|
|
|
NULL, /* init master */
|
2006-08-30 18:39:17 +08:00
|
|
|
NULL, /* init module */
|
2005-09-08 22:36:09 +08:00
|
|
|
NULL, /* init process */
|
|
|
|
NULL, /* init thread */
|
|
|
|
NULL, /* exit thread */
|
|
|
|
NULL, /* exit process */
|
|
|
|
NULL, /* exit master */
|
|
|
|
NGX_MODULE_V1_PADDING
|
2004-10-25 23:29:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static u_char title[] =
|
|
|
|
"<html>" CRLF
|
|
|
|
"<head><title>Index of "
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
static u_char header[] =
|
|
|
|
"</title></head>" CRLF
|
|
|
|
"<body bgcolor=\"white\">" CRLF
|
|
|
|
"<h1>Index of "
|
|
|
|
;
|
|
|
|
|
|
|
|
static u_char tail[] =
|
|
|
|
"</body>" CRLF
|
|
|
|
"</html>" CRLF
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2005-03-04 22:06:57 +08:00
|
|
|
static ngx_int_t
|
|
|
|
ngx_http_autoindex_handler(ngx_http_request_t *r)
|
2004-10-25 23:29:23 +08:00
|
|
|
{
|
2005-10-07 21:30:52 +08:00
|
|
|
u_char *last, *filename, scale;
|
2005-07-08 22:34:20 +08:00
|
|
|
off_t length;
|
2008-07-25 22:29:05 +08:00
|
|
|
size_t len, utf_len, allocated, root;
|
2004-10-25 23:29:23 +08:00
|
|
|
ngx_tm_t tm;
|
|
|
|
ngx_err_t err;
|
|
|
|
ngx_buf_t *b;
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_int_t rc, size;
|
|
|
|
ngx_str_t path;
|
2004-10-25 23:29:23 +08:00
|
|
|
ngx_dir_t dir;
|
2009-05-25 23:57:43 +08:00
|
|
|
ngx_uint_t i, level, utf8;
|
2004-10-25 23:29:23 +08:00
|
|
|
ngx_pool_t *pool;
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_time_t *tp;
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_chain_t out;
|
2004-10-25 23:29:23 +08:00
|
|
|
ngx_array_t entries;
|
|
|
|
ngx_http_autoindex_entry_t *entry;
|
|
|
|
ngx_http_autoindex_loc_conf_t *alcf;
|
|
|
|
|
|
|
|
static char *months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
|
|
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
|
|
|
|
|
|
|
if (r->uri.data[r->uri.len - 1] != '/') {
|
|
|
|
return NGX_DECLINED;
|
|
|
|
}
|
|
|
|
|
2006-05-04 23:32:46 +08:00
|
|
|
if (!(r->method & (NGX_HTTP_GET|NGX_HTTP_HEAD))) {
|
2006-04-19 23:30:56 +08:00
|
|
|
return NGX_DECLINED;
|
|
|
|
}
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
alcf = ngx_http_get_module_loc_conf(r, ngx_http_autoindex_module);
|
|
|
|
|
|
|
|
if (!alcf->enable) {
|
|
|
|
return NGX_DECLINED;
|
|
|
|
}
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
/* NGX_DIR_MASK_LEN is lesser than NGX_HTTP_AUTOINDEX_PREALLOCATE */
|
2004-10-25 23:29:23 +08:00
|
|
|
|
2006-10-12 21:36:54 +08:00
|
|
|
last = ngx_http_map_uri_to_path(r, &path, &root,
|
|
|
|
NGX_HTTP_AUTOINDEX_PREALLOCATE);
|
2005-10-07 21:30:52 +08:00
|
|
|
if (last == NULL) {
|
|
|
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
allocated = path.len;
|
2007-11-08 23:21:54 +08:00
|
|
|
path.len = last - path.data;
|
|
|
|
if (path.len > 1) {
|
|
|
|
path.len--;
|
|
|
|
}
|
2005-10-07 21:30:52 +08:00
|
|
|
path.data[path.len] = '\0';
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
2005-10-07 21:30:52 +08:00
|
|
|
"http autoindex: \"%s\"", path.data);
|
2004-10-25 23:29:23 +08:00
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
if (ngx_open_dir(&path, &dir) == NGX_ERROR) {
|
2004-10-25 23:29:23 +08:00
|
|
|
err = ngx_errno;
|
|
|
|
|
2005-09-23 19:02:22 +08:00
|
|
|
if (err == NGX_ENOENT
|
|
|
|
|| err == NGX_ENOTDIR
|
|
|
|
|| err == NGX_ENAMETOOLONG)
|
|
|
|
{
|
2004-10-25 23:29:23 +08:00
|
|
|
level = NGX_LOG_ERR;
|
|
|
|
rc = NGX_HTTP_NOT_FOUND;
|
|
|
|
|
|
|
|
} else if (err == NGX_EACCES) {
|
|
|
|
level = NGX_LOG_ERR;
|
|
|
|
rc = NGX_HTTP_FORBIDDEN;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
level = NGX_LOG_CRIT;
|
|
|
|
rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_log_error(level, r->connection->log, err,
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_open_dir_n " \"%s\" failed", path.data);
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if (NGX_SUPPRESS_WARN)
|
2005-10-07 21:30:52 +08:00
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
/* MSVC thinks 'entries' may be used without having been initialized */
|
|
|
|
ngx_memzero(&entries, sizeof(ngx_array_t));
|
2005-10-07 21:30:52 +08:00
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
#endif
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
/* TODO: pool should be temporary pool */
|
|
|
|
pool = r->pool;
|
|
|
|
|
|
|
|
if (ngx_array_init(&entries, pool, 40, sizeof(ngx_http_autoindex_entry_t))
|
|
|
|
!= NGX_OK)
|
2004-10-25 23:29:23 +08:00
|
|
|
{
|
2005-10-07 21:30:52 +08:00
|
|
|
return ngx_http_autoindex_error(r, &dir, &path);
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
2005-06-16 02:33:41 +08:00
|
|
|
r->headers_out.status = NGX_HTTP_OK;
|
2006-11-14 04:53:37 +08:00
|
|
|
r->headers_out.content_type_len = sizeof("text/html") - 1;
|
2010-05-14 17:56:37 +08:00
|
|
|
ngx_str_set(&r->headers_out.content_type, "text/html");
|
2005-06-16 02:33:41 +08:00
|
|
|
|
|
|
|
rc = ngx_http_send_header(r);
|
|
|
|
|
|
|
|
if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {
|
2007-09-23 01:56:05 +08:00
|
|
|
if (ngx_close_dir(&dir) == NGX_ERROR) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
|
|
|
|
ngx_close_dir_n " \"%V\" failed", &path);
|
|
|
|
}
|
|
|
|
|
2005-06-16 02:33:41 +08:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
filename = path.data;
|
|
|
|
filename[path.len] = '/';
|
2004-10-25 23:29:23 +08:00
|
|
|
|
2009-05-25 23:57:43 +08:00
|
|
|
if (r->headers_out.charset.len == 5
|
|
|
|
&& ngx_strncasecmp(r->headers_out.charset.data, (u_char *) "utf-8", 5)
|
|
|
|
== 0)
|
|
|
|
{
|
|
|
|
utf8 = 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
utf8 = 0;
|
|
|
|
}
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
for ( ;; ) {
|
|
|
|
ngx_set_errno(0);
|
|
|
|
|
|
|
|
if (ngx_read_dir(&dir) == NGX_ERROR) {
|
|
|
|
err = ngx_errno;
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
if (err != NGX_ENOMOREFILES) {
|
2004-10-25 23:29:23 +08:00
|
|
|
ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_read_dir_n " \"%V\" failed", &path);
|
|
|
|
return ngx_http_autoindex_error(r, &dir, &path);
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
break;
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
|
|
|
"http autoindex file: \"%s\"", ngx_de_name(&dir));
|
|
|
|
|
|
|
|
len = ngx_de_namelen(&dir);
|
|
|
|
|
2005-09-30 22:41:25 +08:00
|
|
|
if (ngx_de_name(&dir)[0] == '.') {
|
2004-10-26 14:27:24 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
if (!dir.valid_info) {
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
/* 1 byte for '/' and 1 byte for terminating '\0' */
|
|
|
|
|
|
|
|
if (path.len + 1 + len + 1 > allocated) {
|
|
|
|
allocated = path.len + 1 + len + 1
|
|
|
|
+ NGX_HTTP_AUTOINDEX_PREALLOCATE;
|
2004-10-25 23:29:23 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
filename = ngx_pnalloc(pool, allocated);
|
2005-10-07 21:30:52 +08:00
|
|
|
if (filename == NULL) {
|
|
|
|
return ngx_http_autoindex_error(r, &dir, &path);
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
last = ngx_cpystrn(filename, path.data, path.len + 1);
|
2004-10-25 23:29:23 +08:00
|
|
|
*last++ = '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
ngx_cpystrn(last, ngx_de_name(&dir), len + 1);
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
if (ngx_de_info(filename, &dir) == NGX_FILE_ERROR) {
|
2005-03-01 23:20:36 +08:00
|
|
|
err = ngx_errno;
|
|
|
|
|
|
|
|
if (err != NGX_ENOENT) {
|
|
|
|
ngx_log_error(NGX_LOG_CRIT, r->connection->log, err,
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_de_info_n " \"%s\" failed", filename);
|
2008-12-08 22:05:21 +08:00
|
|
|
|
|
|
|
if (err == NGX_EACCES) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
return ngx_http_autoindex_error(r, &dir, &path);
|
2005-03-01 23:20:36 +08:00
|
|
|
}
|
|
|
|
|
2005-10-07 21:30:52 +08:00
|
|
|
if (ngx_de_link_info(filename, &dir) == NGX_FILE_ERROR) {
|
2005-03-01 23:20:36 +08:00
|
|
|
ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
|
|
|
|
ngx_de_link_info_n " \"%s\" failed",
|
2005-10-07 21:30:52 +08:00
|
|
|
filename);
|
|
|
|
return ngx_http_autoindex_error(r, &dir, &path);
|
2005-03-01 23:20:36 +08:00
|
|
|
}
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
entry = ngx_array_push(&entries);
|
|
|
|
if (entry == NULL) {
|
2005-10-07 21:30:52 +08:00
|
|
|
return ngx_http_autoindex_error(r, &dir, &path);
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
2005-11-15 21:30:52 +08:00
|
|
|
entry->name.len = len;
|
2005-06-23 21:41:06 +08:00
|
|
|
|
2008-06-17 23:00:30 +08:00
|
|
|
entry->name.data = ngx_pnalloc(pool, len + 1);
|
2005-03-19 20:38:37 +08:00
|
|
|
if (entry->name.data == NULL) {
|
2005-10-07 21:30:52 +08:00
|
|
|
return ngx_http_autoindex_error(r, &dir, &path);
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
2004-11-11 22:07:14 +08:00
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
ngx_cpystrn(entry->name.data, ngx_de_name(&dir), len + 1);
|
|
|
|
|
2005-07-14 20:51:53 +08:00
|
|
|
entry->escape = 2 * ngx_escape_uri(NULL, ngx_de_name(&dir), len,
|
|
|
|
NGX_ESCAPE_HTML);
|
|
|
|
|
2009-05-25 23:57:43 +08:00
|
|
|
if (utf8) {
|
2008-07-29 22:41:34 +08:00
|
|
|
entry->utf_len = ngx_utf8_length(entry->name.data, entry->name.len);
|
2005-06-23 21:41:06 +08:00
|
|
|
} else {
|
|
|
|
entry->utf_len = len;
|
|
|
|
}
|
|
|
|
|
2009-05-18 03:01:23 +08:00
|
|
|
entry->colon = (ngx_strchr(entry->name.data, ':') != NULL);
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
entry->dir = ngx_de_is_dir(&dir);
|
|
|
|
entry->mtime = ngx_de_mtime(&dir);
|
|
|
|
entry->size = ngx_de_size(&dir);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ngx_close_dir(&dir) == NGX_ERROR) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_close_dir_n " \"%s\" failed", &path);
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
len = sizeof(title) - 1
|
|
|
|
+ r->uri.len
|
|
|
|
+ sizeof(header) - 1
|
|
|
|
+ r->uri.len
|
|
|
|
+ sizeof("</h1>") - 1
|
|
|
|
+ sizeof("<hr><pre><a href=\"../\">../</a>" CRLF) - 1
|
|
|
|
+ sizeof("</pre><hr>") - 1
|
|
|
|
+ sizeof(tail) - 1;
|
|
|
|
|
|
|
|
entry = entries.elts;
|
|
|
|
for (i = 0; i < entries.nelts; i++) {
|
|
|
|
len += sizeof("<a href=\"") - 1
|
2005-06-23 21:41:06 +08:00
|
|
|
+ entry[i].name.len + entry[i].escape
|
2005-07-14 20:51:53 +08:00
|
|
|
+ 1 /* 1 is for "/" */
|
2005-06-23 21:41:06 +08:00
|
|
|
+ sizeof("\">") - 1
|
2009-05-18 03:01:23 +08:00
|
|
|
+ entry[i].name.len - entry[i].utf_len + entry[i].colon * 2
|
2005-06-23 21:41:06 +08:00
|
|
|
+ NGX_HTTP_AUTOINDEX_NAME_LEN + sizeof(">") - 2
|
|
|
|
+ sizeof("</a>") - 1
|
|
|
|
+ sizeof(" 28-Sep-1970 12:00 ") - 1
|
2005-07-14 20:51:53 +08:00
|
|
|
+ 20 /* the file size */
|
2005-06-23 21:41:06 +08:00
|
|
|
+ 2;
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
b = ngx_create_temp_buf(r->pool, len);
|
|
|
|
if (b == NULL) {
|
2004-10-25 23:29:23 +08:00
|
|
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entries.nelts > 1) {
|
|
|
|
ngx_qsort(entry, (size_t) entries.nelts,
|
|
|
|
sizeof(ngx_http_autoindex_entry_t),
|
|
|
|
ngx_http_autoindex_cmp_entries);
|
|
|
|
}
|
|
|
|
|
|
|
|
b->last = ngx_cpymem(b->last, title, sizeof(title) - 1);
|
|
|
|
b->last = ngx_cpymem(b->last, r->uri.data, r->uri.len);
|
|
|
|
b->last = ngx_cpymem(b->last, header, sizeof(header) - 1);
|
|
|
|
b->last = ngx_cpymem(b->last, r->uri.data, r->uri.len);
|
|
|
|
b->last = ngx_cpymem(b->last, "</h1>", sizeof("</h1>") - 1);
|
|
|
|
|
|
|
|
b->last = ngx_cpymem(b->last, "<hr><pre><a href=\"../\">../</a>" CRLF,
|
|
|
|
sizeof("<hr><pre><a href=\"../\">../</a>" CRLF) - 1);
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
tp = ngx_timeofday();
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
for (i = 0; i < entries.nelts; i++) {
|
|
|
|
b->last = ngx_cpymem(b->last, "<a href=\"", sizeof("<a href=\"") - 1);
|
2004-11-11 22:07:14 +08:00
|
|
|
|
2009-05-18 03:01:23 +08:00
|
|
|
if (entry[i].colon) {
|
|
|
|
*b->last++ = '.';
|
|
|
|
*b->last++ = '/';
|
|
|
|
}
|
|
|
|
|
2004-11-11 22:07:14 +08:00
|
|
|
if (entry[i].escape) {
|
|
|
|
ngx_escape_uri(b->last, entry[i].name.data, entry[i].name.len,
|
|
|
|
NGX_ESCAPE_HTML);
|
|
|
|
|
|
|
|
b->last += entry[i].name.len + entry[i].escape;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
b->last = ngx_cpymem(b->last, entry[i].name.data,
|
|
|
|
entry[i].name.len);
|
|
|
|
}
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
if (entry[i].dir) {
|
|
|
|
*b->last++ = '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
*b->last++ = '"';
|
|
|
|
*b->last++ = '>';
|
|
|
|
|
2005-06-23 21:41:06 +08:00
|
|
|
len = entry[i].utf_len;
|
2004-10-25 23:29:23 +08:00
|
|
|
|
2008-07-25 22:29:05 +08:00
|
|
|
if (entry[i].name.len != len) {
|
2005-07-08 22:34:20 +08:00
|
|
|
if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) {
|
2008-07-25 22:29:05 +08:00
|
|
|
utf_len = NGX_HTTP_AUTOINDEX_NAME_LEN - 3 + 1;
|
2005-07-08 22:34:20 +08:00
|
|
|
|
|
|
|
} else {
|
2008-07-25 22:29:05 +08:00
|
|
|
utf_len = NGX_HTTP_AUTOINDEX_NAME_LEN + 1;
|
2005-07-08 22:34:20 +08:00
|
|
|
}
|
|
|
|
|
2008-07-29 22:41:34 +08:00
|
|
|
b->last = ngx_utf8_cpystrn(b->last, entry[i].name.data,
|
|
|
|
utf_len, entry[i].name.len + 1);
|
2005-07-08 22:34:20 +08:00
|
|
|
last = b->last;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
b->last = ngx_cpystrn(b->last, entry[i].name.data,
|
|
|
|
NGX_HTTP_AUTOINDEX_NAME_LEN + 1);
|
|
|
|
last = b->last - 3;
|
|
|
|
}
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
if (len > NGX_HTTP_AUTOINDEX_NAME_LEN) {
|
2005-07-08 22:34:20 +08:00
|
|
|
b->last = ngx_cpymem(last, "..></a>", sizeof("..></a>") - 1);
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
if (entry[i].dir && NGX_HTTP_AUTOINDEX_NAME_LEN - len > 0) {
|
|
|
|
*b->last++ = '/';
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
|
|
|
|
b->last = ngx_cpymem(b->last, "</a>", sizeof("</a>") - 1);
|
|
|
|
ngx_memset(b->last, ' ', NGX_HTTP_AUTOINDEX_NAME_LEN - len);
|
|
|
|
b->last += NGX_HTTP_AUTOINDEX_NAME_LEN - len;
|
|
|
|
}
|
|
|
|
|
|
|
|
*b->last++ = ' ';
|
|
|
|
|
2005-10-19 20:33:58 +08:00
|
|
|
ngx_gmtime(entry[i].mtime + tp->gmtoff * 60 * alcf->localtime, &tm);
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
b->last = ngx_sprintf(b->last, "%02d-%s-%d %02d:%02d ",
|
|
|
|
tm.ngx_tm_mday,
|
|
|
|
months[tm.ngx_tm_mon - 1],
|
|
|
|
tm.ngx_tm_year,
|
|
|
|
tm.ngx_tm_hour,
|
|
|
|
tm.ngx_tm_min);
|
|
|
|
|
2005-07-08 22:34:20 +08:00
|
|
|
if (alcf->exact_size) {
|
|
|
|
if (entry[i].dir) {
|
|
|
|
b->last = ngx_cpymem(b->last, " -",
|
|
|
|
sizeof(" -") - 1);
|
|
|
|
} else {
|
|
|
|
b->last = ngx_sprintf(b->last, "%19O", entry[i].size);
|
2005-11-15 21:30:52 +08:00
|
|
|
}
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
} else {
|
2005-07-08 22:34:20 +08:00
|
|
|
if (entry[i].dir) {
|
2005-09-30 22:41:25 +08:00
|
|
|
b->last = ngx_cpymem(b->last, " -",
|
|
|
|
sizeof(" -") - 1);
|
2005-07-08 22:34:20 +08:00
|
|
|
|
|
|
|
} else {
|
|
|
|
length = entry[i].size;
|
|
|
|
|
|
|
|
if (length > 1024 * 1024 * 1024 - 1) {
|
|
|
|
size = (ngx_int_t) (length / (1024 * 1024 * 1024));
|
|
|
|
if ((length % (1024 * 1024 * 1024))
|
|
|
|
> (1024 * 1024 * 1024 / 2 - 1))
|
2005-11-15 21:30:52 +08:00
|
|
|
{
|
2005-07-08 22:34:20 +08:00
|
|
|
size++;
|
|
|
|
}
|
|
|
|
scale = 'G';
|
|
|
|
|
|
|
|
} else if (length > 1024 * 1024 - 1) {
|
|
|
|
size = (ngx_int_t) (length / (1024 * 1024));
|
|
|
|
if ((length % (1024 * 1024)) > (1024 * 1024 / 2 - 1)) {
|
|
|
|
size++;
|
|
|
|
}
|
|
|
|
scale = 'M';
|
|
|
|
|
|
|
|
} else if (length > 9999) {
|
|
|
|
size = (ngx_int_t) (length / 1024);
|
|
|
|
if (length % 1024 > 511) {
|
|
|
|
size++;
|
|
|
|
}
|
|
|
|
scale = 'K';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
size = (ngx_int_t) length;
|
2005-09-30 22:41:25 +08:00
|
|
|
scale = '\0';
|
2005-07-08 22:34:20 +08:00
|
|
|
}
|
|
|
|
|
2005-09-30 22:41:25 +08:00
|
|
|
if (scale) {
|
|
|
|
b->last = ngx_sprintf(b->last, "%6i%c", size, scale);
|
2005-07-08 22:34:20 +08:00
|
|
|
|
2005-09-30 22:41:25 +08:00
|
|
|
} else {
|
|
|
|
b->last = ngx_sprintf(b->last, " %6i", size);
|
2005-07-08 22:34:20 +08:00
|
|
|
}
|
|
|
|
}
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
*b->last++ = CR;
|
|
|
|
*b->last++ = LF;
|
|
|
|
}
|
|
|
|
|
2004-10-26 14:27:24 +08:00
|
|
|
/* TODO: free temporary pool */
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
b->last = ngx_cpymem(b->last, "</pre><hr>", sizeof("</pre><hr>") - 1);
|
|
|
|
|
|
|
|
b->last = ngx_cpymem(b->last, tail, sizeof(tail) - 1);
|
|
|
|
|
2006-01-11 23:26:57 +08:00
|
|
|
if (r == r->main) {
|
2004-10-25 23:29:23 +08:00
|
|
|
b->last_buf = 1;
|
|
|
|
}
|
|
|
|
|
nginx-0.1.29-RELEASE import
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; the bug had appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
2005-05-12 22:58:06 +08:00
|
|
|
b->last_in_chain = 1;
|
|
|
|
|
2004-10-25 23:29:23 +08:00
|
|
|
out.buf = b;
|
|
|
|
out.next = NULL;
|
|
|
|
|
|
|
|
return ngx_http_output_filter(r, &out);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-23 00:02:46 +08:00
|
|
|
static int ngx_libc_cdecl
|
2005-03-04 22:06:57 +08:00
|
|
|
ngx_http_autoindex_cmp_entries(const void *one, const void *two)
|
2004-10-25 23:29:23 +08:00
|
|
|
{
|
|
|
|
ngx_http_autoindex_entry_t *first = (ngx_http_autoindex_entry_t *) one;
|
|
|
|
ngx_http_autoindex_entry_t *second = (ngx_http_autoindex_entry_t *) two;
|
|
|
|
|
|
|
|
if (first->dir && !second->dir) {
|
|
|
|
/* move the directories to the start */
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!first->dir && second->dir) {
|
|
|
|
/* move the directories to the start */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) ngx_strcmp(first->name.data, second->name.data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
2005-03-04 22:06:57 +08:00
|
|
|
static ngx_buf_t *
|
|
|
|
ngx_http_autoindex_alloc(ngx_http_autoindex_ctx_t *ctx, size_t size)
|
2004-10-25 23:29:23 +08:00
|
|
|
{
|
|
|
|
ngx_chain_t *cl;
|
|
|
|
|
|
|
|
if (ctx->buf) {
|
|
|
|
|
|
|
|
if ((size_t) (ctx->buf->end - ctx->buf->last) >= size) {
|
|
|
|
return ctx->buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
ctx->size += ctx->buf->last - ctx->buf->pos;
|
|
|
|
}
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
ctx->buf = ngx_create_temp_buf(ctx->pool, ctx->alloc_size);
|
|
|
|
if (ctx->buf == NULL) {
|
2004-10-25 23:29:23 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-03-19 20:38:37 +08:00
|
|
|
cl = ngx_alloc_chain_link(ctx->pool);
|
|
|
|
if (cl == NULL) {
|
2004-10-25 23:29:23 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cl->buf = ctx->buf;
|
|
|
|
cl->next = NULL;
|
|
|
|
|
|
|
|
*ctx->last_out = cl;
|
|
|
|
ctx->last_out = &cl->next;
|
|
|
|
|
|
|
|
return ctx->buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2005-03-04 22:06:57 +08:00
|
|
|
static ngx_int_t
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_http_autoindex_error(ngx_http_request_t *r, ngx_dir_t *dir, ngx_str_t *name)
|
2004-10-25 23:29:23 +08:00
|
|
|
{
|
|
|
|
if (ngx_close_dir(dir) == NGX_ERROR) {
|
|
|
|
ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
|
2005-10-07 21:30:52 +08:00
|
|
|
ngx_close_dir_n " \"%V\" failed", name);
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NGX_HTTP_INTERNAL_SERVER_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-04 22:06:57 +08:00
|
|
|
static void *
|
|
|
|
ngx_http_autoindex_create_loc_conf(ngx_conf_t *cf)
|
2004-10-25 23:29:23 +08:00
|
|
|
{
|
|
|
|
ngx_http_autoindex_loc_conf_t *conf;
|
|
|
|
|
|
|
|
conf = ngx_palloc(cf->pool, sizeof(ngx_http_autoindex_loc_conf_t));
|
|
|
|
if (conf == NULL) {
|
2009-06-03 00:09:44 +08:00
|
|
|
return NULL;
|
2004-10-25 23:29:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
conf->enable = NGX_CONF_UNSET;
|
2005-05-27 02:12:40 +08:00
|
|
|
conf->localtime = NGX_CONF_UNSET;
|
2005-07-08 22:34:20 +08:00
|
|
|
conf->exact_size = NGX_CONF_UNSET;
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
return conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-04 22:06:57 +08:00
|
|
|
static char *
|
|
|
|
ngx_http_autoindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
2004-10-25 23:29:23 +08:00
|
|
|
{
|
|
|
|
ngx_http_autoindex_loc_conf_t *prev = parent;
|
|
|
|
ngx_http_autoindex_loc_conf_t *conf = child;
|
|
|
|
|
|
|
|
ngx_conf_merge_value(conf->enable, prev->enable, 0);
|
2005-05-27 02:12:40 +08:00
|
|
|
ngx_conf_merge_value(conf->localtime, prev->localtime, 0);
|
2005-07-08 22:34:20 +08:00
|
|
|
ngx_conf_merge_value(conf->exact_size, prev->exact_size, 1);
|
2004-10-25 23:29:23 +08:00
|
|
|
|
|
|
|
return NGX_CONF_OK;
|
|
|
|
}
|
2006-08-30 18:39:17 +08:00
|
|
|
|
|
|
|
|
|
|
|
static ngx_int_t
|
|
|
|
ngx_http_autoindex_init(ngx_conf_t *cf)
|
|
|
|
{
|
|
|
|
ngx_http_handler_pt *h;
|
|
|
|
ngx_http_core_main_conf_t *cmcf;
|
|
|
|
|
|
|
|
cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
|
|
|
|
|
|
|
|
h = ngx_array_push(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers);
|
|
|
|
if (h == NULL) {
|
|
|
|
return NGX_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
*h = ngx_http_autoindex_handler;
|
|
|
|
|
|
|
|
return NGX_OK;
|
|
|
|
}
|