1 /* ====================================================================
2 * Copyright (c) 1995-1998 The Apache Group. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * 3. All advertising materials mentioning features or use of this
17 * software must display the following acknowledgment:
18 * "This product includes software developed by the Apache Group
19 * for use in the Apache HTTP server project (http://www.apache.org/)."
21 * 4. The names "Apache Server" and "Apache Group" must not be used to
22 * endorse or promote products derived from this software without
23 * prior written permission. For written permission, please contact
26 * 5. Products derived from this software may not be called "Apache"
27 * nor may "Apache" appear in their names without prior written
28 * permission of the Apache Group.
30 * 6. Redistributions of any form whatsoever must retain the following
32 * "This product includes software developed by the Apache Group
33 * for use in the Apache HTTP server project (http://www.apache.org/)."
35 * THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
36 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
38 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE GROUP OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
41 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
42 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
43 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
44 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
45 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
46 * OF THE POSSIBILITY OF SUCH DAMAGE.
47 * ====================================================================
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Group and was originally based
51 * on public domain software written at the National Center for
52 * Supercomputing Applications, University of Illinois, Urbana-Champaign.
53 * For more information on the Apache Group and the Apache HTTP server
54 * project, please see <http://www.apache.org/>.
58 #ifndef APACHE_HTTPD_H
59 #define APACHE_HTTPD_H
66 * httpd.h: header for simple (ha! not anymore) http daemon
69 /* Headers in which EVERYONE has an interest... */
71 #include "ap_config.h"
76 /* ----------------------------- config dir ------------------------------ */
78 /* Define this to be the default server home dir. Most things later in this
79 * file with a relative pathname will have this added.
83 /* Set default for OS/2 file system */
84 #define HTTPD_ROOT "/os2httpd"
86 /* Set default for Windows file system */
87 #define HTTPD_ROOT "/apache"
89 #define HTTPD_ROOT "/usr/local/apache"
91 #endif /* HTTPD_ROOT */
93 /* Default location of documents. Can be overridden by the DocumentRoot
96 #ifndef DOCUMENT_LOCATION
98 /* Set default for OS/2 file system */
99 #define DOCUMENT_LOCATION HTTPD_ROOT "/docs"
101 #define DOCUMENT_LOCATION HTTPD_ROOT "/htdocs"
103 #endif /* DOCUMENT_LOCATION */
105 /* Max. number of dynamically loaded modules */
106 #ifndef DYNAMIC_MODULE_LIMIT
107 #define DYNAMIC_MODULE_LIMIT 64
110 /* Default administrator's address */
111 #define DEFAULT_ADMIN "[no address given]"
114 * --------- You shouldn't have to edit anything below this line ----------
116 * Any modifications to any defaults not defined above should be done in the
117 * respective config. file.
122 /* -- Internal representation for a HTTP protocol number, e.g., HTTP/1.1 -- */
124 #define HTTP_VERSION(major,minor) (1000*(major)+(minor))
127 /* -------------- Port number for server running standalone --------------- */
129 #define DEFAULT_HTTP_PORT 80
130 #define DEFAULT_HTTPS_PORT 443
131 #define ap_is_default_port(port,r) ((port) == ap_default_port(r))
132 #define ap_http_method(r) "http"
133 #define ap_default_port(r) DEFAULT_HTTP_PORT
135 /* --------- Default user name and group name running standalone ---------- */
136 /* --- These may be specified as numbers by placing a # before a number --- */
139 #define DEFAULT_USER "#-1"
141 #ifndef DEFAULT_GROUP
142 #define DEFAULT_GROUP "#-1"
145 /* The name of the log files */
146 #ifndef DEFAULT_XFERLOG
148 /* Set default for OS/2 file system */
149 #define DEFAULT_XFERLOG "logs/access.log"
151 #define DEFAULT_XFERLOG "logs/access_log"
153 #endif /* DEFAULT_XFERLOG */
155 #ifndef DEFAULT_ERRORLOG
157 /* Set default for OS/2 file system */
158 #define DEFAULT_ERRORLOG "logs/error.log"
160 #define DEFAULT_ERRORLOG "logs/error_log"
162 #endif /* DEFAULT_ERRORLOG */
164 #ifndef DEFAULT_PIDLOG
165 #define DEFAULT_PIDLOG "logs/httpd.pid"
167 #ifndef DEFAULT_SCOREBOARD
168 #define DEFAULT_SCOREBOARD "logs/apache_runtime_status"
170 #ifndef DEFAULT_LOCKFILE
171 #define DEFAULT_LOCKFILE "logs/accept.lock"
174 /* Define this to be what your HTML directory content files are called */
175 #ifndef DEFAULT_INDEX
176 #define DEFAULT_INDEX "index.html"
179 /* Define this to 1 if you want fancy indexing, 0 otherwise */
180 #ifndef DEFAULT_INDEXING
181 #define DEFAULT_INDEXING 0
184 /* Define this to be what type you'd like returned for files with unknown */
185 /* suffixes. MUST be all lower case. */
186 #ifndef DEFAULT_CONTENT_TYPE
187 #define DEFAULT_CONTENT_TYPE "text/plain"
190 /* Define this to be what your per-directory security files are called */
191 #ifndef DEFAULT_ACCESS_FNAME
193 /* Set default for OS/2 file system */
194 #define DEFAULT_ACCESS_FNAME "htaccess"
196 #define DEFAULT_ACCESS_FNAME ".htaccess"
198 #endif /* DEFAULT_ACCESS_FNAME */
200 /* The name of the server config file */
201 #ifndef SERVER_CONFIG_FILE
202 #define SERVER_CONFIG_FILE "conf/httpd.conf"
205 /* The name of the document config file */
206 #ifndef RESOURCE_CONFIG_FILE
207 #define RESOURCE_CONFIG_FILE "conf/srm.conf"
210 /* The name of the MIME types file */
211 #ifndef TYPES_CONFIG_FILE
212 #define TYPES_CONFIG_FILE "conf/mime.types"
215 /* The name of the access file */
216 #ifndef ACCESS_CONFIG_FILE
217 #define ACCESS_CONFIG_FILE "conf/access.conf"
220 /* Whether we should enable rfc1413 identity checking */
221 #ifndef DEFAULT_RFC1413
222 #define DEFAULT_RFC1413 0
224 /* The default directory in user's home dir */
225 #ifndef DEFAULT_USER_DIR
226 #define DEFAULT_USER_DIR "public_html"
229 /* The default path for CGI scripts if none is currently set */
231 #define DEFAULT_PATH "/bin:/usr/bin:/usr/ucb:/usr/bsd:/usr/local/bin"
234 /* The path to the shell interpreter, for parsed docs */
236 #if defined(__EMX__) || defined(WIN32)
237 /* Set default for OS/2 and Windows file system */
238 #define SHELL_PATH "CMD.EXE"
240 #define SHELL_PATH "/bin/sh"
242 #endif /* SHELL_PATH */
244 /* The path to the suExec wrapper, can be overridden in Configuration */
246 #define SUEXEC_BIN HTTPD_ROOT "/sbin/suexec"
249 /* The default string lengths */
250 #define MAX_STRING_LEN HUGE_STRING_LEN
251 #define HUGE_STRING_LEN 8192
253 /* The timeout for waiting for messages */
254 #ifndef DEFAULT_TIMEOUT
255 #define DEFAULT_TIMEOUT 300
258 /* The timeout for waiting for keepalive timeout until next request */
259 #ifndef DEFAULT_KEEPALIVE_TIMEOUT
260 #define DEFAULT_KEEPALIVE_TIMEOUT 15
263 /* The number of requests to entertain per connection */
264 #ifndef DEFAULT_KEEPALIVE
265 #define DEFAULT_KEEPALIVE 100
268 /* The size of the server's internal read-write buffers */
269 #define IOBUFSIZE 8192
271 /* Number of servers to spawn off by default --- also, if fewer than
272 * this free when the caretaker checks, it will spawn more.
274 #ifndef DEFAULT_START_DAEMON
275 #define DEFAULT_START_DAEMON 5
278 /* Maximum number of *free* server processes --- more than this, and
282 #ifndef DEFAULT_MAX_FREE_DAEMON
283 #define DEFAULT_MAX_FREE_DAEMON 10
286 /* Minimum --- fewer than this, and more will be created */
288 #ifndef DEFAULT_MIN_FREE_DAEMON
289 #define DEFAULT_MIN_FREE_DAEMON 5
292 /* Limit on the total --- clients will be locked out if more servers than
293 * this are needed. It is intended solely to keep the server from crashing
294 * when things get out of hand.
296 * We keep a hard maximum number of servers, for two reasons --- first off,
297 * in case something goes seriously wrong, we want to stop the fork bomb
298 * short of actually crashing the machine we're running on by filling some
299 * kernel table. Secondly, it keeps the size of the scoreboard file small
300 * enough that we can read the whole thing without worrying too much about
303 #ifndef HARD_SERVER_LIMIT
304 #define HARD_SERVER_LIMIT 256
308 * Special Apache error codes. These are basically used
309 * in http_main.c so we can keep track of various errors.
314 * A fatal error arising during the server's init sequence
316 * The child died during it's init sequence
318 * A fatal error, resulting in the whole server aborting.
319 * If a child exits with this error, the parent process
320 * considers this a server-wide fatal error and aborts.
323 #define APEXIT_OK 0x0
324 #define APEXIT_INIT 0x2
325 #define APEXIT_CHILDINIT 0x3
326 #define APEXIT_CHILDFATAL 0xf
330 * Interval, in microseconds, between scoreboard maintenance. During
331 * each scoreboard maintenance cycle the parent decides if it needs to
332 * spawn a new child (to meet MinSpareServers requirements), or kill off
333 * a child (to meet MaxSpareServers requirements). It will only spawn or
334 * kill one child per cycle. Setting this too low will chew cpu. The
335 * default is probably sufficient for everyone. But some people may want
336 * to raise this on servers which aren't dedicated to httpd and where they
337 * don't like the httpd waking up each second to see what's going on.
339 #ifndef SCOREBOARD_MAINTENANCE_INTERVAL
340 #define SCOREBOARD_MAINTENANCE_INTERVAL 1000000
343 /* Number of requests to try to handle in a single process. If <= 0,
344 * the children don't die off. That's the default here, since I'm still
345 * interested in finding and stanching leaks.
348 #ifndef DEFAULT_MAX_REQUESTS_PER_CHILD
349 #define DEFAULT_MAX_REQUESTS_PER_CHILD 0
352 #ifndef DEFAULT_THREADS_PER_CHILD
353 #define DEFAULT_THREADS_PER_CHILD 50
355 #ifndef DEFAULT_EXCESS_REQUESTS_PER_CHILD
356 #define DEFAULT_EXCESS_REQUESTS_PER_CHILD 0
359 /* The maximum length of the queue of pending connections, as defined
360 * by listen(2). Under some systems, it should be increased if you
361 * are experiencing a heavy TCP SYN flood attack.
363 * It defaults to 511 instead of 512 because some systems store it
364 * as an 8-bit datatype; 512 truncated to 8-bits is 0, while 511 is
365 * 255 when truncated.
368 #ifndef DEFAULT_LISTENBACKLOG
369 #define DEFAULT_LISTENBACKLOG 511
373 * The below defines the base string of the Server: header. Additional
374 * tokens can be added via the ap_add_version_component() API call.
376 * The tokens are listed in order of their significance for identifying the
379 * "Product tokens should be short and to the point -- use of them for
380 * advertizing or other non-essential information is explicitly forbidden."
382 * Example: "Apache/1.1.0 MrWidget/0.1-alpha"
385 #define SERVER_BASEVERSION "Apache/1.3.1" /* SEE COMMENTS ABOVE */
386 #define SERVER_VERSION SERVER_BASEVERSION
387 enum server_token_type
{
388 SrvTk_MIN
, /* eg: Apache/1.3.0 */
389 SrvTk_OS
, /* eg: Apache/1.3.0 (UNIX) */
390 SrvTk_FULL
/* eg: Apache/1.3.0 (UNIX) PHP/3.0 FooBar/1.2b */
393 API_EXPORT(const char *) ap_get_server_version(void);
394 API_EXPORT(void) ap_add_version_component(const char *component
);
395 API_EXPORT(const char *) ap_get_server_built(void);
397 /* Numeric release version identifier: major minor bugfix betaseq
398 * Always increases along the same track as the source branch.
399 * For a final release, 'betaseq' should be set to '99'.
400 * For example, Apache 1.4.2 should be '1040299'
402 #define APACHE_RELEASE 1030199
404 #define SERVER_PROTOCOL "HTTP/1.1"
405 #ifndef SERVER_SUPPORT
406 #define SERVER_SUPPORT "http://www.apache.org/"
409 #define DECLINED -1 /* Module declines to handle */
410 #define DONE -2 /* Module has served the response completely
411 * - it's safe to die() with no more output
413 #define OK 0 /* Module has handled this stage. */
416 /* ----------------------- HTTP Status Codes ------------------------- */
418 #define RESPONSE_CODES 38
420 #define HTTP_CONTINUE 100
421 #define HTTP_SWITCHING_PROTOCOLS 101
423 #define HTTP_CREATED 201
424 #define HTTP_ACCEPTED 202
425 #define HTTP_NON_AUTHORITATIVE 203
426 #define HTTP_NO_CONTENT 204
427 #define HTTP_RESET_CONTENT 205
428 #define HTTP_PARTIAL_CONTENT 206
429 #define HTTP_MULTIPLE_CHOICES 300
430 #define HTTP_MOVED_PERMANENTLY 301
431 #define HTTP_MOVED_TEMPORARILY 302
432 #define HTTP_SEE_OTHER 303
433 #define HTTP_NOT_MODIFIED 304
434 #define HTTP_USE_PROXY 305
435 #define HTTP_BAD_REQUEST 400
436 #define HTTP_UNAUTHORIZED 401
437 #define HTTP_PAYMENT_REQUIRED 402
438 #define HTTP_FORBIDDEN 403
439 #define HTTP_NOT_FOUND 404
440 #define HTTP_METHOD_NOT_ALLOWED 405
441 #define HTTP_NOT_ACCEPTABLE 406
442 #define HTTP_PROXY_AUTHENTICATION_REQUIRED 407
443 #define HTTP_REQUEST_TIME_OUT 408
444 #define HTTP_CONFLICT 409
445 #define HTTP_GONE 410
446 #define HTTP_LENGTH_REQUIRED 411
447 #define HTTP_PRECONDITION_FAILED 412
448 #define HTTP_REQUEST_ENTITY_TOO_LARGE 413
449 #define HTTP_REQUEST_URI_TOO_LARGE 414
450 #define HTTP_UNSUPPORTED_MEDIA_TYPE 415
451 #define HTTP_INTERNAL_SERVER_ERROR 500
452 #define HTTP_NOT_IMPLEMENTED 501
453 #define HTTP_BAD_GATEWAY 502
454 #define HTTP_SERVICE_UNAVAILABLE 503
455 #define HTTP_GATEWAY_TIME_OUT 504
456 #define HTTP_VERSION_NOT_SUPPORTED 505
457 #define HTTP_VARIANT_ALSO_VARIES 506
459 #define DOCUMENT_FOLLOWS HTTP_OK
460 #define PARTIAL_CONTENT HTTP_PARTIAL_CONTENT
461 #define MULTIPLE_CHOICES HTTP_MULTIPLE_CHOICES
462 #define MOVED HTTP_MOVED_PERMANENTLY
463 #define REDIRECT HTTP_MOVED_TEMPORARILY
464 #define USE_LOCAL_COPY HTTP_NOT_MODIFIED
465 #define BAD_REQUEST HTTP_BAD_REQUEST
466 #define AUTH_REQUIRED HTTP_UNAUTHORIZED
467 #define FORBIDDEN HTTP_FORBIDDEN
468 #define NOT_FOUND HTTP_NOT_FOUND
469 #define METHOD_NOT_ALLOWED HTTP_METHOD_NOT_ALLOWED
470 #define NOT_ACCEPTABLE HTTP_NOT_ACCEPTABLE
471 #define LENGTH_REQUIRED HTTP_LENGTH_REQUIRED
472 #define PRECONDITION_FAILED HTTP_PRECONDITION_FAILED
473 #define SERVER_ERROR HTTP_INTERNAL_SERVER_ERROR
474 #define NOT_IMPLEMENTED HTTP_NOT_IMPLEMENTED
475 #define BAD_GATEWAY HTTP_BAD_GATEWAY
476 #define VARIANT_ALSO_VARIES HTTP_VARIANT_ALSO_VARIES
478 #define is_HTTP_INFO(x) (((x) >= 100)&&((x) < 200))
479 #define is_HTTP_SUCCESS(x) (((x) >= 200)&&((x) < 300))
480 #define is_HTTP_REDIRECT(x) (((x) >= 300)&&((x) < 400))
481 #define is_HTTP_ERROR(x) (((x) >= 400)&&((x) < 600))
482 #define is_HTTP_CLIENT_ERROR(x) (((x) >= 400)&&((x) < 500))
483 #define is_HTTP_SERVER_ERROR(x) (((x) >= 500)&&((x) < 600))
485 #define status_drops_connection(x) (((x) == HTTP_BAD_REQUEST) || \
486 ((x) == HTTP_REQUEST_TIME_OUT) || \
487 ((x) == HTTP_LENGTH_REQUIRED) || \
488 ((x) == HTTP_REQUEST_ENTITY_TOO_LARGE) || \
489 ((x) == HTTP_REQUEST_URI_TOO_LARGE) || \
490 ((x) == HTTP_INTERNAL_SERVER_ERROR) || \
491 ((x) == HTTP_SERVICE_UNAVAILABLE) || \
492 ((x) == HTTP_NOT_IMPLEMENTED))
505 #define CGI_MAGIC_TYPE "application/x-httpd-cgi"
506 #define INCLUDES_MAGIC_TYPE "text/x-server-parsed-html"
507 #define INCLUDES_MAGIC_TYPE3 "text/x-server-parsed-html3"
508 #ifdef CHARSET_EBCDIC
509 #define ASCIITEXT_MAGIC_TYPE_PREFIX "text/x-ascii-" /* Text files whose content-type starts with this are passed thru unconverted */
510 #endif /*CHARSET_EBCDIC */
511 #define MAP_FILE_MAGIC_TYPE "application/x-type-map"
512 #define ASIS_MAGIC_TYPE "httpd/send-as-is"
513 #define DIR_MAGIC_TYPE "httpd/unix-directory"
514 #define STATUS_MAGIC_TYPE "application/x-httpd-status"
516 /* Just in case your linefeed isn't the one the other end is expecting. */
517 #ifndef CHARSET_EBCDIC
520 #else /* CHARSET_EBCDIC */
522 /* OSD_POSIX uses the EBCDIC charset. The transition ASCII->EBCDIC is done in
523 * the buff package (bread/bputs/bwrite), so everywhere else, we use
524 * "native EBCDIC" CR and NL characters. These are therefore defined as
526 * NB: this is not the whole truth - sometimes \015 and \012 are contained
527 * in literal (EBCDIC!) strings, so these are not converted but passed.
531 #endif /* CHARSET_EBCDIC */
533 /* Possible values for request_rec.read_body (set by handling module):
534 * REQUEST_NO_BODY Send 413 error if message has any body
535 * REQUEST_CHUNKED_ERROR Send 411 error if body without Content-Length
536 * REQUEST_CHUNKED_DECHUNK If chunked, remove the chunks for me.
537 * REQUEST_CHUNKED_PASS Pass the chunks to me without removal.
539 #define REQUEST_NO_BODY 0
540 #define REQUEST_CHUNKED_ERROR 1
541 #define REQUEST_CHUNKED_DECHUNK 2
542 #define REQUEST_CHUNKED_PASS 3
544 /* Things which may vary per file-lookup WITHIN a request ---
545 * e.g., state of MIME config. Basically, the name of an object, info
546 * about the object, and any other info we may ahve which may need to
547 * change as we go poking around looking for it (e.g., overridden by
550 * Note how the default state of almost all these things is properly
551 * zero, so that allocating it with pcalloc does the right thing without
552 * a whole lot of hairy initialization... so long as we are willing to
553 * make the (fairly) portable assumption that the bit pattern of a NULL
554 * pointer is, in fact, zero.
557 /* This represents the result of calling htaccess; these are cached for
560 struct htaccess_result
{
561 char *dir
; /* the directory to which this applies */
562 int override
; /* the overrides allowed for the .htaccess file */
563 void *htaccess
; /* the configuration directives */
564 /* the next one, or NULL if no more; N.B. never change this */
565 const struct htaccess_result
*next
;
568 typedef struct afs_conn_rec conn_rec
;
569 typedef struct server_rec server_rec
;
570 typedef struct request_rec request_rec
;
571 typedef struct listen_rec listen_rec
;
573 #include "util_uri.h"
578 conn_rec
*connection
;
581 request_rec
*next
; /* If we wind up getting redirected,
582 * pointer to the request we redirected to.
584 request_rec
*prev
; /* If this is an internal redirect,
585 * pointer to where we redirected *from*.
588 request_rec
*main
; /* If this is a sub_request (see request.h)
589 * pointer back to the main request.
592 /* Info about the request itself... we begin with stuff that only
593 * protocol.c should ever touch...
596 char *the_request
; /* First line of request, so we can log it */
597 int assbackwards
; /* HTTP/0.9, "simple" request */
598 int proxyreq
; /* A proxy request (calculated during
599 * post_read_request or translate_name) */
600 int header_only
; /* HEAD request, as opposed to GET */
601 char *protocol
; /* Protocol, as given to us, or HTTP/0.9 */
602 int proto_num
; /* Number version of protocol; 1.1 = 1001 */
603 const char *hostname
; /* Host, as set by full URI or Host: */
605 time_t request_time
; /* When the request started */
607 char *status_line
; /* Status line, if set by script */
608 int status
; /* In any case */
610 /* Request method, two ways; also, protocol, etc.. Outside of protocol.c,
611 * look, but don't touch.
614 char *method
; /* GET, HEAD, POST, etc. */
615 int method_number
; /* M_GET, M_POST, etc. */
618 * allowed is a bitvector of the allowed methods.
620 * A handler must ensure that the request method is one that
621 * it is capable of handling. Generally modules should DECLINE
622 * any request methods they do not handle. Prior to aborting the
623 * handler like this the handler should set r->allowed to the list
624 * of methods that it is willing to handle. This bitvector is used
625 * to construct the "Allow:" header required for OPTIONS requests,
626 * and METHOD_NOT_ALLOWED and NOT_IMPLEMENTED status codes.
628 * Since the default_handler deals with OPTIONS, all modules can
629 * usually decline to deal with OPTIONS. TRACE is always allowed,
630 * modules don't need to set it explicitly.
632 * Since the default_handler will always handle a GET, a
633 * module which does *not* implement GET should probably return
634 * METHOD_NOT_ALLOWED. Unfortunately this means that a Script GET
635 * handler can't be installed by mod_actions.
637 int allowed
; /* Allowed methods - for 405, OPTIONS, etc */
639 int sent_bodyct
; /* byte count in stream is for body */
640 long bytes_sent
; /* body byte count, for easy access */
641 time_t mtime
; /* Time the resource was last modified */
643 /* HTTP/1.1 connection-level features */
645 int chunked
; /* sending chunked transfer-coding */
646 int byterange
; /* number of byte ranges */
647 char *boundary
; /* multipart/byteranges boundary */
648 const char *range
; /* The Range: header */
649 long clength
; /* The "real" content length */
651 long remaining
; /* bytes left to read */
652 long read_length
; /* bytes that have been read */
653 int read_body
; /* how the request body should be read */
654 int read_chunked
; /* reading chunked transfer-coding */
656 /* MIME header environments, in and out. Also, an array containing
657 * environment variables to be passed to subprocesses, so people can
658 * write modules to add to that environment.
660 * The difference between headers_out and err_headers_out is that the
661 * latter are printed even on error, and persist across internal redirects
662 * (so the headers printed for ErrorDocument handlers will have them).
664 * The 'notes' table is for notes from one module to another, with no
665 * other set purpose in mind...
670 table
*err_headers_out
;
671 table
*subprocess_env
;
674 /* content_type, handler, content_encoding, content_language, and all
675 * content_languages MUST be lowercased strings. They may be pointers
676 * to static strings; they should not be modified in place.
678 const char *content_type
; /* Break these out --- we dispatch on 'em */
679 const char *handler
; /* What we *really* dispatch on */
681 const char *content_encoding
;
682 const char *content_language
; /* for back-compat. only -- do not use */
683 array_header
*content_languages
; /* array of (char*) */
688 /* What object is being requested (either directly, or via include
689 * or content-negotiation mapping).
692 char *unparsed_uri
; /* the uri without any parsing performed */
693 char *uri
; /* the path portion of the URI */
696 char *args
; /* QUERY_ARGS, if any */
697 struct stat finfo
; /* ST_MODE set to zero if no such file */
698 uri_components parsed_uri
; /* components of uri, dismantled */
700 /* Various other config info which may change with .htaccess files
701 * These are config vectors, with one void* pointer for each module
702 * (the thing pointed to being the module's business).
705 void *per_dir_config
; /* Options set in config files, etc. */
706 void *request_config
; /* Notes on *this* request */
709 * a linked list of the configuration directives in the .htaccess files
710 * accessed by this request.
711 * N.B. always add to the head of the list, _never_ to the end.
712 * that way, a sub request's list can (temporarily) point to a parent's list
714 const struct htaccess_result
*htaccess
;
718 /* Things which are per connection
721 struct afs_conn_rec
{
725 server_rec
*base_server
; /* Physical vhost this conn come in on */
726 void *vhost_lookup_data
; /* used by http_vhost.c */
728 /* Information about the connection itself */
730 int child_num
; /* The number of the child handling conn_rec */
731 BUFF
*client
; /* Connection to the guy */
733 /* Who is the client? */
735 struct sockaddr_in local_addr
; /* local address */
736 struct sockaddr_in remote_addr
; /* remote address */
737 char *remote_ip
; /* Client's IP address */
738 char *remote_host
; /* Client's DNS name, if known.
739 * NULL if DNS hasn't been checked,
740 * "" if it has and no address was found.
741 * N.B. Only access this though
742 * get_remote_host() */
743 char *remote_logname
; /* Only ever set if doing rfc1413 lookups.
744 * N.B. Only access this through
745 * get_remote_logname() */
746 char *user
; /* If an authentication check was made,
747 * this gets set to the user name. We assume
748 * that there's only one user per connection(!)
750 char *ap_auth_type
; /* Ditto. */
752 unsigned aborted
:1; /* Are we still talking? */
753 signed int keepalive
:2; /* Are we using HTTP Keep-Alive?
754 * -1 fatal error, 0 undecided, 1 yes */
755 unsigned keptalive
:1; /* Did we use HTTP Keep-Alive? */
756 signed int double_reverse
:2; /* have we done double-reverse DNS?
757 * -1 yes/failure, 0 not yet, 1 yes/success */
758 int keepalives
; /* How many times have we used it? */
761 /* Per-vhost config... */
763 /* The address 255.255.255.255, when used as a virtualhost address,
764 * will become the "default" server when the ip doesn't match other vhosts.
766 #define DEFAULT_VHOST_ADDR 0xfffffffful
768 typedef struct server_addr_rec server_addr_rec
;
769 struct server_addr_rec
{
770 server_addr_rec
*next
;
771 struct in_addr host_addr
; /* The bound address, for this server */
772 unsigned short host_port
; /* The bound port, for this server */
773 char *virthost
; /* The name given in <VirtualHost> */
780 /* description of where the definition came from */
781 const char *defn_name
;
782 unsigned defn_line_number
;
784 /* Full locations of server config info */
787 char *access_confname
;
789 /* Contact information */
792 char *server_hostname
;
793 unsigned short port
; /* for redirects, etc. */
795 /* Log files --- note that transfer log is now in the modules... */
801 /* Module-specific configuration for server, and defaults... */
803 int is_virtual
; /* true if this is the virtual server */
804 void *module_config
; /* Config vector containing pointers to
805 * modules' per-server config structures.
807 void *lookup_defaults
; /* MIME type info, etc., before we start
808 * checking per-directory info.
810 /* Transaction handling */
812 server_addr_rec
*addrs
;
813 int timeout
; /* Timeout, in seconds, before we give up */
814 int keep_alive_timeout
; /* Seconds we'll wait for another request */
815 int keep_alive_max
; /* Maximum requests per connection */
816 int keep_alive
; /* Use persistent connections? */
817 int send_buffer_size
; /* size of TCP send buffer (in bytes) */
819 char *path
; /* Pathname for ServerPath */
820 int pathlen
; /* Length of path */
822 array_header
*names
; /* Normal names for ServerAlias servers */
823 array_header
*wild_names
; /* Wildcarded names for ServerAlias servers */
825 uid_t server_uid
; /* effective user id when calling exec wrapper */
826 gid_t server_gid
; /* effective group id when calling exec wrapper */
829 /* These are more like real hosts than virtual hosts */
832 struct sockaddr_in local_addr
; /* local IP address and port */
834 int used
; /* Only used during restart */
835 /* more stuff here, like which protocol is bound to the port */
838 /* Prototypes for utilities... util.c.
841 extern void ap_util_init(void);
844 extern API_VAR_EXPORT
const char ap_month_snames
[12][4];
845 extern API_VAR_EXPORT
const char ap_day_snames
[7][4];
847 API_EXPORT(struct tm
*) ap_get_gmtoff(int *tz
);
848 API_EXPORT(char *) ap_get_time(void);
849 API_EXPORT(char *) ap_ht_time(pool
* p
, time_t t
, const char *fmt
,
851 API_EXPORT(char *) ap_gm_timestr_822(pool
* p
, time_t t
);
853 /* String handling. The *_nc variants allow you to use non-const char **s as
854 arguments (unfortunately C won't automatically convert a char ** to a const
857 API_EXPORT(char *) ap_getword(pool
* p
, const char **line
, char stop
);
858 API_EXPORT(char *) ap_getword_nc(pool
* p
, char **line
, char stop
);
859 API_EXPORT(char *) ap_getword_white(pool
* p
, const char **line
);
860 API_EXPORT(char *) ap_getword_white_nc(pool
* p
, char **line
);
861 API_EXPORT(char *) ap_getword_nulls(pool
* p
, const char **line
,
863 API_EXPORT(char *) ap_getword_nulls_nc(pool
* p
, char **line
,
865 API_EXPORT(char *) ap_getword_conf(pool
* p
, const char **line
);
866 API_EXPORT(char *) ap_getword_conf_nc(pool
* p
, char **line
);
868 API_EXPORT(char *) ap_get_token(pool
* p
, const char **accept_line
,
870 API_EXPORT(int) ap_find_token(pool
* p
, const char *line
,
872 API_EXPORT(int) ap_find_last_token(pool
* p
, const char *line
,
875 API_EXPORT(int) ap_is_url(const char *u
);
876 API_EXPORT(int) ap_unescape_url(char *url
);
877 API_EXPORT(void) ap_no2slash(char *name
);
878 API_EXPORT(void) ap_getparents(char *name
);
879 API_EXPORT(char *) ap_escape_path_segment(pool
* p
, const char *s
);
880 API_EXPORT(char *) ap_os_escape_path(pool
* p
, const char *path
,
882 #define escape_uri(ppool,path) ap_os_escape_path(ppool,path,1)
883 API_EXPORT(char *) ap_escape_html(pool
* p
, const char *s
);
884 API_EXPORT(char *) ap_construct_server(pool
* p
, const char *hostname
,
886 const request_rec
* r
);
887 API_EXPORT(char *) ap_escape_shell_cmd(pool
* p
, const char *s
);
889 API_EXPORT(int) ap_count_dirs(const char *path
);
890 API_EXPORT(char *) ap_make_dirstr_prefix(char *d
, const char *s
, int n
);
891 API_EXPORT(char *) ap_make_dirstr_parent(pool
* p
, const char *s
);
892 /* deprecated. The previous two routines are preferred. */
893 API_EXPORT(char *) ap_make_dirstr(pool
* a
, const char *s
, int n
);
894 API_EXPORT(char *) ap_make_full_path(pool
* a
, const char *dir
,
897 API_EXPORT(int) ap_is_matchexp(const char *str
);
898 API_EXPORT(int) ap_strcmp_match(const char *str
, const char *exp
);
899 API_EXPORT(int) ap_strcasecmp_match(const char *str
, const char *exp
);
900 API_EXPORT(char *) ap_uudecode(pool
*, const char *);
902 void os2pathname(char *path
);
905 API_EXPORT(char *) ap_pregsub(pool
* p
, const char *input
,
906 const char *source
, size_t nmatch
,
907 regmatch_t pmatch
[]);
909 API_EXPORT(void) ap_content_type_tolower(char *);
910 API_EXPORT(void) ap_str_tolower(char *);
911 API_EXPORT(int) ap_ind(const char *, char); /* Sigh... */
912 API_EXPORT(int) ap_rind(const char *, char);
914 API_EXPORT(char *) ap_escape_quotes(pool
* p
, const char *instring
);
916 /* Common structure for reading of config files / passwd files etc. */
918 int (*getch
) (void *param
); /* a getc()-like function */
919 void *(*getstr
) (void *buf
, size_t bufsiz
, void *param
); /* a fgets()-like function */
920 int (*close
) (void *param
); /* a close hander function */
921 void *param
; /* the argument passed to getch/getstr/close */
922 const char *name
; /* the filename / description */
923 unsigned line_number
; /* current line number, starting at 1 */
926 /* Open a configfile_t as FILE, return open configfile_t struct pointer */
927 API_EXPORT(configfile_t
*) ap_pcfg_openfile(pool
* p
, const char *name
);
929 /* Allocate a configfile_t handle with user defined functions and params */
930 API_EXPORT(configfile_t
*) ap_pcfg_open_custom(pool
* p
,
933 int (*getc_func
) (void
935 void *(*gets_func
) (void
941 int (*close_func
) (void
944 /* Read one line from open configfile_t, strip LF, increase line number */
945 API_EXPORT(int) ap_cfg_getline(char *buf
, size_t bufsize
,
948 /* Read one char from open configfile_t, increase line number upon LF */
949 API_EXPORT(int) ap_cfg_getc(configfile_t
* cfp
);
951 /* Detach from open configfile_t, calling the close handler */
952 API_EXPORT(int) ap_cfg_closefile(configfile_t
* cfp
);
955 char *strerror(int err
);
958 /* Misc system hackery */
960 API_EXPORT(uid_t
) ap_uname2id(const char *name
);
961 API_EXPORT(gid_t
) ap_gname2id(const char *name
);
962 API_EXPORT(int) ap_is_directory(const char *name
);
963 API_EXPORT(int) ap_can_exec(const struct stat
*);
964 API_EXPORT(void) ap_chdir_file(const char *file
);
966 #ifndef HAVE_CANONICAL_FILENAME
967 #define ap_os_canonical_filename(p,f) (f)
969 API_EXPORT(char *) ap_os_canonical_filename(pool
* p
, const char *file
);
973 extern const char *os_set_authfile(pool
* p
, const char *filename
);
974 extern int os_init_job_environment(server_rec
* s
, const char *user_name
);
975 #endif /* _OSD_POSIX */
977 char *ap_get_local_host(pool
*);
978 unsigned long ap_get_virthost_addr(const char *hostname
,
979 unsigned short *port
);
981 extern API_VAR_EXPORT
time_t ap_restart_time
;
984 * Apache tries to keep all of its long term filehandles (such as log files,
985 * and sockets) above this number. This is to workaround problems in many
986 * third party libraries that are compiled with a small FD_SETSIZE. There
987 * should be no reason to lower this, because it's only advisory. If a file
988 * can't be allocated above this number then it will remain in the "slack"
991 * Only the low slack line is used by default. If HIGH_SLACK_LINE is defined
992 * then an attempt is also made to keep all non-FILE * files above the high
993 * slack line. This is to work around a Solaris C library limitation, where it
994 * uses an unsigned char to store the file descriptor.
996 #ifndef LOW_SLACK_LINE
997 #define LOW_SLACK_LINE 15
999 /* #define HIGH_SLACK_LINE 255 */
1002 * The ap_slack() function takes a fd, and tries to move it above the indicated
1003 * line. It returns an fd which may or may not have moved above the line, and
1004 * never fails. If the high line was requested and it fails it will also try
1008 #define ap_slack(fd,line) (fd)
1010 int ap_slack(int fd
, int line
);
1011 #define AP_SLACK_LOW 1
1012 #define AP_SLACK_HIGH 2
1015 API_EXPORT(char *) ap_escape_quotes(pool
* p
, const char *instr
);
1018 * Redefine assert() to something more useful for an Apache...
1020 API_EXPORT(void) ap_log_assert(const char *szExp
, const char *szFile
,
1022 __attribute__ ((noreturn
));
1023 #define ap_assert(exp) (void)( (exp) || (ap_log_assert(#exp, __FILE__, __LINE__), 0) )
1025 /* The optimized timeout code only works if we're not MULTITHREAD and we're
1026 * also not using a scoreboard file
1028 #if !defined (MULTITHREAD) && \
1029 (defined (USE_MMAP_SCOREBOARD) || defined (USE_SHMGET_SCOREBOARD))
1030 #define OPTIMIZE_TIMEOUTS
1033 /* A set of flags which indicate places where the server should raise(SIGSTOP).
1034 * This is useful for debugging, because you can then attach to that process
1035 * with gdb and continue. This is important in cases where one_process
1036 * debugging isn't possible.
1038 #define SIGSTOP_DETACH 1
1039 #define SIGSTOP_MAKE_CHILD 2
1040 #define SIGSTOP_SPAWN_CHILD 4
1041 #define SIGSTOP_PIPED_LOG_SPAWN 8
1042 #define SIGSTOP_CGI_CHILD 16
1044 #ifdef DEBUG_SIGSTOP
1045 extern int raise_sigstop_flags
;
1046 #define RAISE_SIGSTOP(x) do { \
1047 if (raise_sigstop_flags & SIGSTOP_##x) raise(SIGSTOP);\
1050 #define RAISE_SIGSTOP(x)
1053 API_EXPORT(extern const char *) ap_psignature(const char *prefix
,
1056 /* strtoul does not exist on sunos4. */
1060 #define strtoul strtoul_is_not_a_portable_function_use_strtol_instead
1065 #endif /* !APACHE_HTTPD_H */