blob: d0539e0466fac53172e27ad3eb950592256e7a39 [file] [log] [blame]
Igor Sysoev4e9393a2003-01-09 05:36:00 +00001#ifndef _NGX_HTTP_CORE_H_INCLUDED_
2#define _NGX_HTTP_CORE_H_INCLUDED_
3
4
5#include <ngx_string.h>
6#include <ngx_array.h>
7#include <ngx_http.h>
8
9
10typedef struct {
Igor Sysoeva8fa0a62003-11-25 20:44:56 +000011 in_addr_t addr;
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000012 int port;
13 int family;
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000014 ngx_str_t file_name;
15 int line;
Igor Sysoev10a543a2004-03-16 07:10:12 +000016
17 unsigned default_server:1;
Igor Sysoev4e9393a2003-01-09 05:36:00 +000018} ngx_http_listen_t;
19
20
Igor Sysoev865c1502003-11-30 20:03:18 +000021typedef enum {
22 NGX_HTTP_REWRITE_PHASE = 0,
23 NGX_HTTP_FIND_CONFIG_PHASE,
24 NGX_HTTP_CONTENT_PHASE,
25 NGX_HTTP_LAST_PHASE
26} ngx_http_phases;
27
28
Igor Sysoev4e9393a2003-01-09 05:36:00 +000029typedef struct {
Igor Sysoevb3e73d82003-10-10 15:10:50 +000030 ngx_array_t handlers;
Igor Sysoev10a543a2004-03-16 07:10:12 +000031 ngx_int_t type; /* NGX_OK, NGX_DECLINED */
Igor Sysoevb3e73d82003-10-10 15:10:50 +000032} ngx_http_phase_t;
33
Igor Sysoevb3e73d82003-10-10 15:10:50 +000034
35typedef struct {
36 ngx_array_t servers; /* array of ngx_http_core_srv_conf_t */
37
38 ngx_http_phase_t phases[NGX_HTTP_LAST_PHASE];
39 ngx_array_t index_handlers;
Igor Sysoevbb4ec5c2003-05-16 15:27:48 +000040} ngx_http_core_main_conf_t;
41
42
43typedef struct {
Igor Sysoeva9830112003-05-19 16:39:14 +000044 ngx_array_t locations; /* array of ngx_http_core_loc_conf_t,
45 used in the translation handler
46 and in the merge phase */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000047
48 ngx_array_t listen; /* 'listen', array of ngx_http_listen_t */
49 ngx_array_t server_names; /* 'server_name',
50 array of ngx_http_server_name_t */
Igor Sysoeva9830112003-05-19 16:39:14 +000051
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000052 ngx_http_conf_ctx_t *ctx; /* server ctx */
Igor Sysoev187fcd82003-05-23 11:53:01 +000053
Igor Sysoev10a543a2004-03-16 07:10:12 +000054 size_t connection_pool_size;
55 size_t request_pool_size;
56 size_t client_header_buffer_size;
57
Igor Sysoev239baac2003-06-11 15:28:34 +000058 ngx_msec_t post_accept_timeout;
Igor Sysoev187fcd82003-05-23 11:53:01 +000059 ngx_msec_t client_header_timeout;
Igor Sysoev10a543a2004-03-16 07:10:12 +000060
Igor Sysoev3043bfc2004-05-14 16:51:47 +000061 ngx_uint_t restrict_host_names;
62
Igor Sysoev10a543a2004-03-16 07:10:12 +000063 ngx_flag_t large_client_header;
Igor Sysoev4e9393a2003-01-09 05:36:00 +000064} ngx_http_core_srv_conf_t;
65
66
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000067/* list of structures to find core_srv_conf quickly at run time */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000068
69typedef struct {
70 int port;
Igor Sysoev6253ca12003-05-27 12:18:54 +000071 ngx_str_t port_name;
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000072 ngx_array_t addrs; /* array of ngx_http_in_addr_t */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000073} ngx_http_in_port_t;
74
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000075
Igor Sysoev4e9393a2003-01-09 05:36:00 +000076typedef struct {
Igor Sysoeva8fa0a62003-11-25 20:44:56 +000077 in_addr_t addr;
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000078 ngx_array_t names; /* array of ngx_http_server_name_t */
79 ngx_http_core_srv_conf_t *core_srv_conf; /* default server conf
80 for this address:port */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000081
Igor Sysoev10a543a2004-03-16 07:10:12 +000082 unsigned default_server:1;
83} ngx_http_in_addr_t;
Igor Sysoev4e9393a2003-01-09 05:36:00 +000084
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000085
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000086typedef struct {
87 ngx_str_t name;
88 ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */
89} ngx_http_server_name_t;
90
91
Igor Sysoev79a80482003-05-14 17:13:13 +000092#define NGX_HTTP_TYPES_HASH_PRIME 13
93
94#define ngx_http_types_hash_key(key, ext) \
95 { \
Igor Sysoev1c13c662003-05-20 15:37:55 +000096 u_int n; \
Igor Sysoev79a80482003-05-14 17:13:13 +000097 for (key = 0, n = 0; n < ext.len; n++) { \
98 key += ext.data[n]; \
99 } \
100 key %= NGX_HTTP_TYPES_HASH_PRIME; \
101 }
102
103typedef struct {
104 ngx_str_t exten;
105 ngx_str_t type;
106} ngx_http_type_t;
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000107
108
109typedef struct {
Igor Sysoev3f4685f2004-04-25 20:13:21 +0000110 ngx_int_t status;
111 ngx_int_t overwrite;
Igor Sysoev74e95c22003-11-09 20:03:38 +0000112 ngx_str_t uri;
113} ngx_http_err_page_t;
114
115
116typedef struct {
Igor Sysoev6253ca12003-05-27 12:18:54 +0000117 ngx_str_t name; /* location name */
118 void **loc_conf ; /* pointer to the modules' loc_conf */
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000119
Igor Sysoev2f657222004-06-16 15:32:11 +0000120 ngx_http_handler_pt handler;
Igor Sysoeve2a31542003-04-08 15:40:10 +0000121
Igor Sysoev10a543a2004-03-16 07:10:12 +0000122 ngx_str_t root; /* root, alias */
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000123
Igor Sysoev79a80482003-05-14 17:13:13 +0000124 ngx_array_t *types;
Igor Sysoev6253ca12003-05-27 12:18:54 +0000125 ngx_str_t default_type;
Igor Sysoev79a80482003-05-14 17:13:13 +0000126
Igor Sysoevae02c192004-03-19 05:25:53 +0000127 size_t client_max_body_size; /* client_max_body_size */
Igor Sysoev10a543a2004-03-16 07:10:12 +0000128 size_t send_lowat; /* send_lowat */
129 size_t discarded_buffer_size; /* discarded_buffer_size */
Igor Sysoevdbb27762004-04-01 16:20:53 +0000130 size_t client_body_buffer_size; /* client_body_buffer_size */
Igor Sysoev10a543a2004-03-16 07:10:12 +0000131
Igor Sysoev2b0c76c2003-10-27 21:01:00 +0000132 ngx_msec_t client_body_timeout; /* client_body_timeout */
Igor Sysoev6253ca12003-05-27 12:18:54 +0000133 ngx_msec_t send_timeout; /* send_timeout */
Igor Sysoev6253ca12003-05-27 12:18:54 +0000134 ngx_msec_t keepalive_timeout; /* keepalive_timeout */
135 ngx_msec_t lingering_time; /* lingering_time */
136 ngx_msec_t lingering_timeout; /* lingering_timeout */
Igor Sysoeve2a31542003-04-08 15:40:10 +0000137
Igor Sysoev10a543a2004-03-16 07:10:12 +0000138 ngx_flag_t sendfile; /* sendfile */
139 ngx_flag_t tcp_nopush; /* tcp_nopush */
Igor Sysoev0ab91b92004-06-06 19:49:18 +0000140 ngx_flag_t reset_timedout_connection; /* reset_timedout_connection */
Igor Sysoev10a543a2004-03-16 07:10:12 +0000141 ngx_flag_t msie_padding; /* msie_padding */
142
Igor Sysoev74e95c22003-11-09 20:03:38 +0000143 ngx_array_t *error_pages; /* error_page */
Igor Sysoev12b4b002003-10-24 06:53:41 +0000144
Igor Sysoev865c1502003-11-30 20:03:18 +0000145 ngx_http_cache_hash_t *open_files;
146
Igor Sysoevdc867cd2003-12-14 20:10:27 +0000147#if (HAVE_PCRE)
Igor Sysoeva8fa0a62003-11-25 20:44:56 +0000148 ngx_regex_t *regex;
Igor Sysoevdc867cd2003-12-14 20:10:27 +0000149#endif
Igor Sysoeva8fa0a62003-11-25 20:44:56 +0000150
151 unsigned exact_match:1;
Igor Sysoev1b138ed2003-11-18 21:34:08 +0000152 unsigned auto_redirect:1;
Igor Sysoev10a543a2004-03-16 07:10:12 +0000153 unsigned alias:1;
Igor Sysoev1b138ed2003-11-18 21:34:08 +0000154
Igor Sysoev9d639522003-07-07 06:11:50 +0000155 ngx_log_t *err_log;
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000156} ngx_http_core_loc_conf_t;
157
158
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000159extern ngx_http_module_t ngx_http_core_module_ctx;
160extern ngx_module_t ngx_http_core_module;
161
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000162extern int ngx_http_max_module;
163
164
165
Igor Sysoev2f657222004-06-16 15:32:11 +0000166ngx_int_t ngx_http_find_location_config(ngx_http_request_t *r);
167ngx_int_t ngx_http_core_translate_handler(ngx_http_request_t *r);
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000168
Igor Sysoev865c1502003-11-30 20:03:18 +0000169ngx_int_t ngx_http_set_content_type(ngx_http_request_t *r);
Igor Sysoev3b30a902003-12-25 20:26:58 +0000170ngx_int_t ngx_http_set_exten(ngx_http_request_t *r);
Igor Sysoev865c1502003-11-30 20:03:18 +0000171
Igor Sysoev2f657222004-06-16 15:32:11 +0000172ngx_int_t ngx_http_internal_redirect(ngx_http_request_t *r,
173 ngx_str_t *uri, ngx_str_t *args);
Igor Sysoevdc479b42003-03-20 16:09:44 +0000174
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000175
Igor Sysoev2f657222004-06-16 15:32:11 +0000176typedef ngx_int_t (*ngx_http_output_header_filter_pt)(ngx_http_request_t *r);
177typedef ngx_int_t (*ngx_http_output_body_filter_pt)
Igor Sysoev0ab91b92004-06-06 19:49:18 +0000178 (ngx_http_request_t *r, ngx_chain_t *chain);
179
180
Igor Sysoev2f657222004-06-16 15:32:11 +0000181ngx_int_t ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *chain);
182ngx_int_t ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *chain);
Igor Sysoev0ab91b92004-06-06 19:49:18 +0000183
184
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000185#endif /* _NGX_HTTP_CORE_H_INCLUDED_ */