17 #ifdef HAVE_INTTYPES_H
18 # include <inttypes.h>
21 #include "base_decls.h"
26 #include "sock_addr.h"
29 struct fdevents
; /* declaration */
30 struct stat_cache
; /* declaration */
38 # define SIZE_MAX SIZE_T_MAX
40 # define SIZE_MAX ((size_t)~0)
45 # define SSIZE_MAX ((size_t)~0 >> 1)
49 #include <crt_externs.h>
50 #define environ (* _NSGetEnviron())
52 extern char **environ
;
55 /* for solaris 2.5 and NetBSD 1.3.x */
56 #ifndef HAVE_SOCKLEN_T
57 typedef int socklen_t
;
60 /* solaris and NetBSD 1.3.x again */
61 #if (!defined(HAVE_STDINT_H)) && (!defined(HAVE_INTTYPES_H)) && (!defined(uint32_t))
62 # define uint32_t u_int32_t
70 typedef enum { T_CONFIG_UNSET
,
79 } config_values_type_t
;
81 typedef enum { T_CONFIG_SCOPE_UNSET
,
82 T_CONFIG_SCOPE_SERVER
,
83 T_CONFIG_SCOPE_CONNECTION
84 } config_scope_type_t
;
90 config_values_type_t type
;
91 config_scope_type_t scope
;
94 typedef enum { DIRECT
, EXTERNAL
} connection_type
;
103 /* fcgi_response_header contains ... */
104 #define HTTP_STATUS BV(0)
105 #define HTTP_CONNECTION BV(1)
106 #define HTTP_CONTENT_LENGTH BV(2)
107 #define HTTP_DATE BV(3)
108 #define HTTP_LOCATION BV(4)
109 #define HTTP_TRANSFER_ENCODING BV(5)
110 #define HTTP_CONTENT_LOCATION BV(6)
111 #define HTTP_SET_COOKIE BV(7)
112 #define HTTP_UPGRADE BV(8)
116 /* the request-line */
122 http_method_t http_method
;
123 http_version_t http_version
;
125 buffer
*request_line
;
127 /* strings to the header */
128 buffer
*http_host
; /* not alloced */
129 const char *http_range
;
130 const char *http_content_type
;
131 const char *http_if_modified_since
;
132 const char *http_if_none_match
;
137 off_t content_length
; /* returned by strtoll() */
140 /* internal representation */
148 off_t content_length
;
149 int keep_alive
; /* used by the subrequests in proxy, cgi and fcgi to say the subrequest was keep-alive or not */
154 HTTP_TRANSFER_ENCODING_IDENTITY
, HTTP_TRANSFER_ENCODING_CHUNKED
159 buffer
*scheme
; /* scheme without colon or slashes ( "http" or "https" ) */
161 /* authority with optional portnumber ("site.name" or "site.name:8080" ) NOTE: without "username:password@" */
164 /* path including leading slash ("/" or "/index.html") - urldecoded, and sanitized ( buffer_path_simplify() && buffer_urldecode_path() ) */
166 buffer
*path_raw
; /* raw path, as sent from client. no urldecoding or path simplifying */
167 buffer
*query
; /* querystring ( everything after "?", ie: in "/index.php?foo=1", query is "foo=1" ) */
172 buffer
*basedir
; /* path = "(basedir)(.*)" */
174 buffer
*doc_root
; /* path = doc_root + rel_path */
196 buffer
*content_type
;
202 /* virtual-servers */
203 buffer
*document_root
;
205 buffer
*error_handler
;
206 buffer
*error_handler_404
;
208 buffer
*dirlist_encoding
;
209 buffer
*errorfile_prefix
;
210 buffer
*socket_perms
;
212 unsigned short high_precision_timestamps
;
213 unsigned short max_keep_alive_requests
;
214 unsigned short max_keep_alive_idle
;
215 unsigned short max_read_idle
;
216 unsigned short max_write_idle
;
217 unsigned short use_xattr
;
218 unsigned short follow_symlink
;
219 unsigned short range_requests
;
220 unsigned short stream_request_body
;
221 unsigned short stream_response_body
;
222 unsigned short error_intercept
;
226 unsigned short log_file_not_found
;
227 unsigned short log_request_header
;
228 unsigned short log_request_handling
;
229 unsigned short log_response_header
;
230 unsigned short log_condition_handling
;
231 unsigned short log_timeouts
;
235 unsigned short use_ipv6
, set_v6only
; /* set_v6only is only a temporary option */
236 unsigned short defer_accept
;
237 unsigned short ssl_enabled
; /* only interesting for setting up listening sockets. don't use at runtime */
238 unsigned short allow_http11
;
239 unsigned short etag_use_inode
;
240 unsigned short etag_use_mtime
;
241 unsigned short etag_use_size
;
242 unsigned short force_lowercase_filenames
; /* if the FS is case-insensitive, force all files to lower-case */
243 unsigned int http_parseopts
;
244 unsigned int max_request_size
;
247 unsigned short kbytes_per_second
; /* connection kb/s limit */
250 unsigned short global_kbytes_per_second
; /* */
252 off_t global_bytes_per_second_cnt
;
253 /* server-wide traffic-shaper
255 * each context has the counter which is inited once
256 * a second by the global_kbytes_per_second config-var
258 * as soon as global_kbytes_per_second gets below 0
259 * the connected conns are "offline" a little bit
262 * we somehow have to loose our "we are writable" signal
266 off_t
*global_bytes_per_second_cnt_ptr
; /* */
268 #if defined(__FreeBSD__) || defined(__NetBSD__) \
269 || defined(__OpenBSD__) || defined(__DragonFly__)
270 buffer
*bsd_accept_filter
;
275 /* the order of the items should be the same as they are processed
276 * read before write as we use this later */
279 CON_STATE_REQUEST_START
,
281 CON_STATE_REQUEST_END
,
283 CON_STATE_HANDLE_REQUEST
,
284 CON_STATE_RESPONSE_START
,
286 CON_STATE_RESPONSE_END
,
289 } connection_state_t
;
292 /* condition not active at the moment because itself or some
293 * pre-condition depends on data not available yet
297 /* special "unset" for branches not selected due to pre-conditions
298 * not met (but pre-conditions are not "unset" anymore)
302 /* actually evaluated the condition itself */
303 COND_RESULT_FALSE
, /* not active */
304 COND_RESULT_TRUE
/* active */
308 /* current result (with preconditions) */
309 cond_result_t result
;
310 /* result without preconditions (must never be "skip") */
311 cond_result_t local_result
;
314 buffer
*comp_value
; /* just a pointer */
318 connection_state_t state
;
322 time_t close_timeout_ts
;
323 time_t write_request_ts
;
325 time_t connection_start
;
326 time_t request_start
;
327 struct timespec request_start_hp
;
329 size_t request_count
; /* number of requests handled in this connection */
330 size_t loops_per_request
; /* to catch endless loops in a single request
332 * used by mod_rewrite, mod_fastcgi, ... and others
333 * this is self-protection
336 int fd
; /* the FD for this connection */
337 int fde_ndx
; /* index for the fdevent-handler */
338 int ndx
; /* reverse mapping to server->connection[ndx] */
344 int keep_alive
; /* only request.c can enable it, all other just disable */
345 int keep_alive_idle
; /* remember max_keep_alive_idle from config */
350 chunkqueue
*write_queue
; /* a large queue for low-level write ( HTTP response ) [ file, mem ] */
351 chunkqueue
*read_queue
; /* a small queue for low-level read ( HTTP request ) [ mem ] */
352 chunkqueue
*request_content_queue
; /* takes request-content into tempfile if necessary [ tempfile, mem ]*/
354 int traffic_limit_reached
;
356 off_t bytes_written
; /* used by mod_accesslog, mod_rrd */
357 off_t bytes_written_cur_second
; /* used by mod_accesslog, mod_rrd */
358 off_t bytes_read
; /* used by mod_accesslog, mod_rrd */
364 buffer
*dst_addr_buf
;
367 buffer
*parse_request
;
368 unsigned int parsed_response
; /* bitfield which contains the important header-fields of the parsed response header */
377 array
*environment
; /* used to pass lighttpd internal stuff to the FastCGI/CGI apps, setenv does that */
379 connection_type mode
;
381 void **plugin_ctx
; /* plugin connection specific config */
383 specific_config conf
; /* global connection specific config */
384 cond_cache_t
*cond_cache
;
390 int error_handler_saved_status
;
391 http_method_t error_handler_saved_method
;
393 struct server_socket
*srv_socket
; /* reference to the server-socket */
394 int (* network_write
)(struct server
*srv
, struct connection
*con
, chunkqueue
*cq
, off_t max_bytes
);
395 int (* network_read
)(struct server
*srv
, struct connection
*con
, chunkqueue
*cq
, off_t max_bytes
);
398 etag_flags_t etag_flags
;
400 int conditional_is_valid
[COMP_LAST_ELEMENT
];
414 } realpath_cache_type
;
417 time_t mtime
; /* the key */
418 buffer
*str
; /* a buffer for the string represenation */
431 buffer
*errorlog_file
;
432 unsigned short errorlog_use_syslog
;
433 buffer
*breakagelog_file
;
435 unsigned short dont_daemonize
;
436 unsigned short preflight_check
;
443 buffer
*event_handler
;
446 buffer
*network_backend
;
448 array
*upload_tempdirs
;
449 unsigned int upload_temp_file_size
;
450 unsigned int max_request_field_size
;
452 unsigned short max_worker
;
453 unsigned short max_fds
;
454 unsigned short max_conns
;
456 unsigned short log_request_header_on_error
;
457 unsigned short log_state_handling
;
459 int stat_cache_engine
;
460 unsigned short enable_cores
;
461 unsigned short reject_expect_100_with_417
;
464 unsigned short http_header_strict
;
465 unsigned short http_host_strict
;
466 unsigned short http_host_normalize
;
467 unsigned short high_precision_timestamps
;
470 buffer
*syslog_facility
;
473 typedef struct server_socket
{
478 unsigned short is_ssl
;
489 } server_socket_array
;
492 server_socket_array srv_sockets
;
496 enum { ERRORLOG_FILE
, ERRORLOG_FD
, ERRORLOG_SYSLOG
, ERRORLOG_PIPE
} errorlog_mode
;
497 buffer
*errorlog_buf
;
501 buffer_plugin plugins
;
510 int max_fds
; /* max possible fds */
511 int cur_fds
; /* currently used fds */
512 int want_fds
; /* waiting fds */
513 int sockets_disabled
;
518 buffer
*parse_full_path
;
519 buffer
*response_header
;
520 buffer
*response_range
;
523 buffer
*tmp_chunk_len
;
525 buffer
*empty_string
; /* is necessary for cond_match */
527 buffer
*cond_check_buf
;
530 mtime_cache_type mtime_cache
[FILE_CACHE_MAX
];
536 time_t last_generated_date_ts
;
537 time_t last_generated_debug_ts
;
540 buffer
*ts_debug_str
;
544 array
*config_touched
;
546 array
*config_context
;
547 specific_config
**config_storage
;
549 server_config srvconf
;
551 short int config_deprecated
;
552 short int config_unsupported
;
555 connections
*joblist
;
556 connections
*fdwaitqueue
;
558 struct stat_cache
*stat_cache
;
561 * The status array can carry all the status information you want
562 * the key to the array is <module-prefix>.<name>
563 * and the values are counters
566 * fastcgi.backends = 10
567 * fastcgi.active-backends = 6
568 * fastcgi.backend.<key>.load = 24
569 * fastcgi.backend.<key>....
571 * fastcgi.backend.<key>.disconnects = ...
577 int (* network_backend_write
)(struct server
*srv
, int fd
, chunkqueue
*cq
, off_t max_bytes
);
578 handler_t (* request_env
)(struct server
*srv
, connection
*con
);