10 #include "base_decls.h"
15 #include "sock_addr.h"
18 struct fdevents
; /* declaration */
19 struct stat_cache
; /* declaration */
21 #define DIRECT 0 /* con->mode */
26 /* the request-line */
32 http_method_t http_method
;
33 http_version_t http_version
;
35 /* strings to the header */
36 buffer
*http_host
; /* not alloced */
38 unsigned int htags
; /* bitfield of flagged headers present in request */
42 off_t content_length
; /* returned by strtoll() */
51 unsigned int htags
; /* bitfield of flagged headers present in response */
57 buffer
*scheme
; /* scheme without colon or slashes ( "http" or "https" ) */
59 /* authority with optional portnumber ("site.name" or "site.name:8080" ) NOTE: without "username:password@" */
62 /* path including leading slash ("/" or "/index.html") - urldecoded, and sanitized ( buffer_path_simplify() && buffer_urldecode_path() ) */
64 buffer
*path_raw
; /* raw path, as sent from client. no urldecoding or path simplifying */
65 buffer
*query
; /* querystring ( everything after "?", ie: in "/index.php?foo=1", query is "foo=1" ) */
70 buffer
*basedir
; /* path = "(basedir)(.*)" */
72 buffer
*doc_root
; /* path = doc_root + rel_path */
82 buffer
*document_root
;
84 buffer
*error_handler
;
85 buffer
*error_handler_404
;
87 buffer
*dirlist_encoding
;
88 buffer
*errorfile_prefix
;
91 unsigned short high_precision_timestamps
;
92 unsigned short max_keep_alive_requests
;
93 unsigned short max_keep_alive_idle
;
94 unsigned short max_read_idle
;
95 unsigned short max_write_idle
;
96 unsigned short use_xattr
;
97 unsigned short follow_symlink
;
98 unsigned short range_requests
;
99 unsigned short stream_request_body
;
100 unsigned short stream_response_body
;
101 unsigned short error_intercept
;
105 unsigned short log_file_not_found
;
106 unsigned short log_request_header
;
107 unsigned short log_request_handling
;
108 unsigned short log_response_header
;
109 unsigned short log_condition_handling
;
110 unsigned short log_timeouts
;
114 unsigned short use_ipv6
, set_v6only
; /* set_v6only is only a temporary option */
115 unsigned short defer_accept
;
116 unsigned short ssl_enabled
; /* only interesting for setting up listening sockets. don't use at runtime */
117 unsigned short allow_http11
;
118 unsigned short etag_use_inode
;
119 unsigned short etag_use_mtime
;
120 unsigned short etag_use_size
;
121 unsigned short force_lowercase_filenames
; /* if the FS is case-insensitive, force all files to lower-case */
122 unsigned int http_parseopts
;
123 unsigned int max_request_size
;
126 unsigned short kbytes_per_second
; /* connection kb/s limit */
129 unsigned short global_kbytes_per_second
; /* */
131 off_t global_bytes_per_second_cnt
;
132 /* server-wide traffic-shaper
134 * each context has the counter which is inited once
135 * a second by the global_kbytes_per_second config-var
137 * as soon as global_kbytes_per_second gets below 0
138 * the connected conns are "offline" a little bit
141 * we somehow have to loose our "we are writable" signal
145 off_t
*global_bytes_per_second_cnt_ptr
; /* */
147 #if defined(__FreeBSD__) || defined(__NetBSD__) \
148 || defined(__OpenBSD__) || defined(__DragonFly__)
149 buffer
*bsd_accept_filter
;
154 /* the order of the items should be the same as they are processed
155 * read before write as we use this later */
158 CON_STATE_REQUEST_START
,
160 CON_STATE_REQUEST_END
,
162 CON_STATE_HANDLE_REQUEST
,
163 CON_STATE_RESPONSE_START
,
165 CON_STATE_RESPONSE_END
,
168 } connection_state_t
;
171 /* condition not active at the moment because itself or some
172 * pre-condition depends on data not available yet
176 /* special "unset" for branches not selected due to pre-conditions
177 * not met (but pre-conditions are not "unset" anymore)
181 /* actually evaluated the condition itself */
182 COND_RESULT_FALSE
, /* not active */
183 COND_RESULT_TRUE
/* active */
186 typedef struct cond_cache_t
{
187 /* current result (with preconditions) */
188 cond_result_t result
;
189 /* result without preconditions (must never be "skip") */
190 cond_result_t local_result
;
193 buffer
*comp_value
; /* just a pointer */
197 connection_state_t state
;
201 time_t close_timeout_ts
;
202 time_t write_request_ts
;
204 time_t connection_start
;
205 time_t request_start
;
206 struct timespec request_start_hp
;
208 size_t request_count
; /* number of requests handled in this connection */
209 size_t loops_per_request
; /* to catch endless loops in a single request
211 * used by mod_rewrite, mod_fastcgi, ... and others
212 * this is self-protection
215 fdnode
*fdn
; /* fdevent (fdnode *) object */
216 int fd
; /* the FD for this connection */
217 int ndx
; /* reverse mapping to server->connection[ndx] */
224 int keep_alive
; /* only request.c can enable it, all other just disable */
225 int keep_alive_idle
; /* remember max_keep_alive_idle from config */
230 chunkqueue
*write_queue
; /* a large queue for low-level write ( HTTP response ) [ file, mem ] */
231 chunkqueue
*read_queue
; /* a small queue for low-level read ( HTTP request ) [ mem ] */
232 chunkqueue
*request_content_queue
; /* takes request-content into tempfile if necessary [ tempfile, mem ]*/
234 int traffic_limit_reached
;
236 off_t bytes_written
; /* used by mod_accesslog, mod_rrd */
237 off_t bytes_written_cur_second
; /* used by mod_accesslog, mod_rrd */
238 off_t bytes_read
; /* used by mod_accesslog, mod_rrd */
244 buffer
*dst_addr_buf
;
254 array
*environment
; /* used to pass lighttpd internal stuff to the FastCGI/CGI apps, setenv does that */
256 unsigned int mode
; /* DIRECT (0) or plugin id */
261 void **plugin_ctx
; /* plugin connection specific config */
263 specific_config conf
; /* global connection specific config */
264 cond_cache_t
*cond_cache
;
270 int error_handler_saved_status
;
271 http_method_t error_handler_saved_method
;
273 struct server_socket
*srv_socket
; /* reference to the server-socket */
274 int (* network_write
)(struct server
*srv
, struct connection
*con
, chunkqueue
*cq
, off_t max_bytes
);
275 int (* network_read
)(struct server
*srv
, struct connection
*con
, chunkqueue
*cq
, off_t max_bytes
);
278 etag_flags_t etag_flags
;
280 int8_t conditional_is_valid
[16]; /* MUST be >= COMP_LAST_ELEMENT] */
290 time_t mtime
; /* the key */
291 buffer
*str
; /* a buffer for the string represenation */
304 buffer
*errorlog_file
;
305 unsigned short errorlog_use_syslog
;
306 buffer
*breakagelog_file
;
308 unsigned short dont_daemonize
;
309 unsigned short preflight_check
;
316 buffer
*event_handler
;
319 buffer
*network_backend
;
321 array
*upload_tempdirs
;
322 unsigned int upload_temp_file_size
;
323 unsigned int max_request_field_size
;
325 unsigned short max_worker
;
326 unsigned short max_fds
;
327 unsigned short max_conns
;
329 unsigned short log_request_header_on_error
;
330 unsigned short log_state_handling
;
332 int stat_cache_engine
;
333 unsigned short enable_cores
;
334 unsigned short reject_expect_100_with_417
;
337 unsigned short http_header_strict
;
338 unsigned short http_host_strict
;
339 unsigned short http_host_normalize
;
340 unsigned short http_url_normalize
;
341 unsigned short http_method_get_body
;
342 unsigned short high_precision_timestamps
;
345 buffer
*syslog_facility
;
347 unsigned short compat_module_load
;
348 unsigned short systemd_socket_activation
;
351 typedef struct server_socket
{
355 unsigned short is_ssl
;
367 } server_socket_array
;
370 server_socket_array srv_sockets
;
374 buffer_plugin plugins
;
383 int max_fds
; /* max possible fds */
384 int max_fds_lowat
;/* low watermark */
385 int max_fds_hiwat
;/* high watermark */
386 int cur_fds
; /* currently used fds */
387 int want_fds
; /* waiting fds */
388 int sockets_disabled
;
393 buffer
*parse_full_path
;
394 buffer
*response_header
;
395 buffer
*response_range
;
398 buffer
*tmp_chunk_len
;
400 buffer
*empty_string
; /* is necessary for cond_match */
402 buffer
*cond_check_buf
;
405 mtime_cache_type mtime_cache
[FILE_CACHE_MAX
];
413 time_t last_generated_date_ts
;
414 time_t last_generated_debug_ts
;
417 buffer
*ts_debug_str
;
421 array
*config_touched
;
423 array
*config_context
;
424 specific_config
**config_storage
;
426 server_config srvconf
;
428 short int config_deprecated
;
429 short int config_unsupported
;
432 connections
*joblist
;
433 connections
*fdwaitqueue
;
435 struct stat_cache
*stat_cache
;
438 * The status array can carry all the status information you want
439 * the key to the array is <module-prefix>.<name>
440 * and the values are counters
443 * fastcgi.backends = 10
444 * fastcgi.active-backends = 6
445 * fastcgi.backend.<key>.load = 24
446 * fastcgi.backend.<key>....
448 * fastcgi.backend.<key>.disconnects = ...
454 int (* network_backend_write
)(struct server
*srv
, int fd
, chunkqueue
*cq
, off_t max_bytes
);
455 handler_t (* request_env
)(struct server
*srv
, connection
*con
);
461 server_socket_array srv_sockets_inherited
;