blob: d44a86c113e1f64950928a34ef59cdb341304d14 [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 Sysoev73009772003-02-06 17:21:13 +000011 u_int32_t addr;
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000012 int port;
13 int family;
14 int flags; /* 'default' */
15 ngx_str_t file_name;
16 int line;
Igor Sysoev4e9393a2003-01-09 05:36:00 +000017} ngx_http_listen_t;
18
19
20typedef struct {
Igor Sysoevbb4ec5c2003-05-16 15:27:48 +000021 int request_pool_size;
22 int client_header_buffer_size;
23} ngx_http_core_main_conf_t;
24
25
26typedef struct {
Igor Sysoev4e9393a2003-01-09 05:36:00 +000027 ngx_array_t locations; /* array of ngx_http_core_loc_conf_t */
28
29 ngx_array_t listen; /* 'listen', array of ngx_http_listen_t */
30 ngx_array_t server_names; /* 'server_name',
31 array of ngx_http_server_name_t */
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000032 ngx_http_conf_ctx_t *ctx; /* server ctx */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000033} ngx_http_core_srv_conf_t;
34
35
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000036/* list of structures to find core_srv_conf quickly at run time */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000037
38typedef struct {
39 int port;
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000040 ngx_array_t addrs; /* array of ngx_http_in_addr_t */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000041} ngx_http_in_port_t;
42
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000043
Igor Sysoev4e9393a2003-01-09 05:36:00 +000044typedef struct {
45 u_int32_t addr;
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000046 ngx_array_t names; /* array of ngx_http_server_name_t */
47 ngx_http_core_srv_conf_t *core_srv_conf; /* default server conf
48 for this address:port */
49 int flags;
Igor Sysoev4e9393a2003-01-09 05:36:00 +000050} ngx_http_in_addr_t;
51
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000052/* ngx_http_in_addr_t's flags */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000053#define NGX_HTTP_DEFAULT_SERVER 1
54
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000055
Igor Sysoevfe5cb6b2003-01-29 07:25:51 +000056typedef struct {
57 ngx_str_t name;
58 ngx_http_core_srv_conf_t *core_srv_conf; /* virtual name server conf */
59} ngx_http_server_name_t;
60
61
Igor Sysoev79a80482003-05-14 17:13:13 +000062#define NGX_HTTP_TYPES_HASH_PRIME 13
63
64#define ngx_http_types_hash_key(key, ext) \
65 { \
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000066 uint n; \
Igor Sysoev79a80482003-05-14 17:13:13 +000067 for (key = 0, n = 0; n < ext.len; n++) { \
68 key += ext.data[n]; \
69 } \
70 key %= NGX_HTTP_TYPES_HASH_PRIME; \
71 }
72
73typedef struct {
74 ngx_str_t exten;
75 ngx_str_t type;
76} ngx_http_type_t;
Igor Sysoev4e9393a2003-01-09 05:36:00 +000077
78
79typedef struct {
80 ngx_str_t name; /* location name */
Igor Sysoeva19a85e2003-01-28 15:56:37 +000081 void **loc_conf; /* pointer to modules loc_conf,
82 used in translation handler */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000083
Igor Sysoeve2a31542003-04-08 15:40:10 +000084 int (*handler) (ngx_http_request_t *r);
85
Igor Sysoevdc479b42003-03-20 16:09:44 +000086 ngx_str_t doc_root; /* root */
Igor Sysoev4e9393a2003-01-09 05:36:00 +000087
Igor Sysoev79a80482003-05-14 17:13:13 +000088 ngx_array_t *types;
89
Igor Sysoeve2a31542003-04-08 15:40:10 +000090 int sendfile; /* sendfile */
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000091 ngx_msec_t send_timeout; /* send_timeout */
Igor Sysoevdc479b42003-03-20 16:09:44 +000092 size_t send_lowat; /* send_lowa */
93 size_t discarded_buffer_size; /* discarded_buffer_size */
Igor Sysoev6ddfbf02003-05-15 15:42:53 +000094 ngx_msec_t lingering_time; /* lingering_time */
Igor Sysoevdc479b42003-03-20 16:09:44 +000095 ngx_msec_t lingering_timeout; /* lingering_timeout */
Igor Sysoeve2a31542003-04-08 15:40:10 +000096
Igor Sysoev4e9393a2003-01-09 05:36:00 +000097} ngx_http_core_loc_conf_t;
98
99
100
101
102#if 0
103typedef struct {
104 int dummy;
105} ngx_http_core_conf_t;
106#endif
107
108
Igor Sysoeve2a31542003-04-08 15:40:10 +0000109#if 0
110#define ngx_http_set_loc_handler(conf_ctx, ngx_http_handler) \
111 { \
112 ngx_http_conf_ctx_t *cx = conf_ctx; \
113 ngx_http_core_loc_conf_t *lcf; \
114 lcf = cx->loc_conf[ngx_http_core_module_ctx.index]; \
115 lcf->handler = ngx_http_handler; \
116 }
117#endif
118
119
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000120extern ngx_http_module_t ngx_http_core_module_ctx;
121extern ngx_module_t ngx_http_core_module;
122
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000123extern int ngx_http_max_module;
124
125
126
127int ngx_http_core_translate_handler(ngx_http_request_t *r);
128
Igor Sysoev73009772003-02-06 17:21:13 +0000129int ngx_http_internal_redirect(ngx_http_request_t *r, ngx_str_t uri);
Igor Sysoev2a2d2b52003-01-30 18:21:39 +0000130int ngx_http_error(ngx_http_request_t *r, int error);
Igor Sysoevdc479b42003-03-20 16:09:44 +0000131
Igor Sysoev4e9393a2003-01-09 05:36:00 +0000132
133#endif /* _NGX_HTTP_CORE_H_INCLUDED_ */