http_core.inc 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. { Licensed to the Apache Software Foundation (ASF) under one or more
  2. * contributor license agreements. See the NOTICE file distributed with
  3. * this work for additional information regarding copyright ownership.
  4. * The ASF licenses this file to You under the Apache License, Version 2.0
  5. * (the "License"); you may not use this file except in compliance with
  6. * the License. You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. }
  16. {****************************************************************
  17. *
  18. * The most basic server code is encapsulated in a single module
  19. * known as the core, which is just *barely* functional enough to
  20. * serve documents, though not terribly well.
  21. *
  22. * Largely for NCSA back-compatibility reasons, the core needs to
  23. * make pieces of its config structures available to other modules.
  24. * The accessors are declared here, along with the interpretation
  25. * of one of them (allow_options).
  26. }
  27. const
  28. OPT_NONE = 0;
  29. OPT_INDEXES = 1;
  30. OPT_INCLUDES = 2;
  31. OPT_SYM_LINKS = 4;
  32. OPT_EXECCGI = 8;
  33. OPT_UNSET = 16;
  34. OPT_INCNOEXEC = 32;
  35. OPT_SYM_OWNER = 64;
  36. OPT_MULTI = 128;
  37. OPT_ALL = (OPT_INDEXES or OPT_INCLUDES or OPT_SYM_LINKS or OPT_EXECCGI);
  38. { options for get_remote_host() }
  39. { REMOTE_HOST returns the hostname, or NULL if the hostname
  40. * lookup fails. It will force a DNS lookup according to the
  41. * HostnameLookups setting.
  42. }
  43. REMOTE_HOST = (0);
  44. { REMOTE_NAME returns the hostname, or the dotted quad if the
  45. * hostname lookup fails. It will force a DNS lookup according
  46. * to the HostnameLookups setting.
  47. }
  48. REMOTE_NAME = (1);
  49. { REMOTE_NOLOOKUP is like REMOTE_NAME except that a DNS lookup is
  50. * never forced.
  51. }
  52. REMOTE_NOLOOKUP = (2);
  53. { REMOTE_DOUBLE_REV will always force a DNS lookup, and also force
  54. * a double reverse lookup, regardless of the HostnameLookups
  55. * setting. The result is the (double reverse checked) hostname,
  56. * or NULL if any of the lookups fail.
  57. }
  58. REMOTE_DOUBLE_REV = (3);
  59. SATISFY_ALL = 0;
  60. SATISFY_ANY = 1;
  61. SATISFY_NOSPEC = 2;
  62. { default maximum of internal redirects }
  63. AP_DEFAULT_MAX_INTERNAL_REDIRECTS = 20;
  64. { default maximum subrequest nesting level }
  65. AP_DEFAULT_MAX_SUBREQ_DEPTH = 20;
  66. function ap_allow_options(r: Prequest_rec): cint;
  67. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  68. function ap_allow_overrides(r: Prequest_rec): cint;
  69. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  70. function ap_default_type(r: Prequest_rec): PChar;
  71. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  72. function ap_document_root(r: Prequest_rec): PChar;
  73. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  74. { Don't use this! If your request went
  75. * through a Userdir, or something like
  76. * that, it'll screw you. But it's
  77. * back-compatible...
  78. }
  79. function ap_get_remote_host(conn: Pconn_rec; dir_config: Pointer; type_: cint): PChar;
  80. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  81. function ap_get_remote_logname(r: Prequest_rec): PChar;
  82. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  83. { Used for constructing self-referencing URLs, and things like SERVER_PORT,
  84. * and SERVER_NAME.
  85. }
  86. function ap_construct_url(p: Ppool; const uri: PChar; r: Prequest_rec): PChar;
  87. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  88. function ap_get_server_name(r: Prequest_rec): PChar;
  89. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  90. function ap_get_server_port(const r: Prequest_rec): cuint;
  91. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  92. function ap_get_limit_req_body(const r: Prequest_rec): culong;
  93. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  94. procedure ap_custom_response(r: Prequest_rec; status: cint; string_: PChar);
  95. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  96. function ap_exists_config_define(name: PChar): cint;
  97. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  98. { Check if the current request is beyond the configured max. number of redirects or subrequests
  99. * @param r The current request
  100. * @return true (is exceeded) or false
  101. }
  102. function ap_is_recursion_limit_exceeded(const r: Prequest_rec): cint;
  103. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  104. { Authentication stuff. This is one of the places where compatibility
  105. * with the old config files *really* hurts; they don't discriminate at
  106. * all between different authentication schemes, meaning that we need
  107. * to maintain common state for all of them in the core, and make it
  108. * available to the other modules through interfaces.
  109. }
  110. type
  111. require_line = record
  112. method_mask: cint;
  113. requirement: PChar;
  114. end;
  115. {API_EXPORT(const char *) ap_auth_type (request_rec *);
  116. API_EXPORT(const char *) ap_auth_name (request_rec *);
  117. API_EXPORT(const char *) ap_auth_nonce (request_rec *);
  118. API_EXPORT(int) ap_satisfies (request_rec *r);
  119. API_EXPORT(const array_header *) ap_requires (request_rec *); }
  120. {$ifdef WINDOWS}
  121. {
  122. * CGI Script stuff for Win32...
  123. }
  124. type
  125. file_type_e = ( eFileTypeUNKNOWN, eFileTypeBIN, eFileTypeEXE16, eFileTypeEXE32,
  126. eFileTypeSCRIPT, eCommandShell16, eCommandShell32 );
  127. interpreter_source_e = ( INTERPRETER_SOURCE_UNSET, INTERPRETER_SOURCE_REGISTRY,
  128. INTERPRETER_SOURCE_SHEBANG );
  129. function ap_get_win32_interpreter(const param1: Prequest_rec; param2: PPChar): file_type_e;
  130. {$IFDEF WINDOWS} stdcall; {$ELSE} cdecl; {$ENDIF} external LibHTTPD;
  131. {$endif}
  132. {.$ifdef CORE_PRIVATE}
  133. {
  134. * Core is also unlike other modules in being implemented in more than
  135. * one file... so, data structures are declared here, even though most of
  136. * the code that cares really is in http_core.c. Also, another accessor.
  137. }
  138. //API_EXPORT(char *) ap_response_code_string (request_rec *r, int error_index);
  139. //extern API_VAR_EXPORT module core_module;
  140. { Per-directory configuration }
  141. type
  142. allow_options_t = Char;
  143. overrides_t = Char
  144. ;
  145. {
  146. * Bits of info that go into making an ETag for a file
  147. * document. Why a long? Because char historically
  148. * proved too short for Options, and int can be different
  149. * sizes on different platforms.
  150. }
  151. etag_components_t = culong;
  152. const
  153. ETAG_UNSET = 0;
  154. ETAG_NONE = (1 shl 0);
  155. ETAG_MTIME = (1 shl 1);
  156. ETAG_INODE = (1 shl 2);
  157. ETAG_SIZE = (1 shl 3);
  158. ETAG_BACKWARD = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE);
  159. ETAG_ALL = (ETAG_MTIME or ETAG_INODE or ETAG_SIZE);
  160. { Things moved up }
  161. HOSTNAME_LOOKUP_OFF = 0;
  162. HOSTNAME_LOOKUP_ON = 1;
  163. HOSTNAME_LOOKUP_DOUBLE= 2;
  164. HOSTNAME_LOOKUP_UNSET = 3;
  165. USE_CANONICAL_NAME_OFF = (0);
  166. USE_CANONICAL_NAME_ON = (1);
  167. USE_CANONICAL_NAME_DNS = (2);
  168. USE_CANONICAL_NAME_UNSET= (3);
  169. ADD_DEFAULT_CHARSET_OFF = (0);
  170. ADD_DEFAULT_CHARSET_ON = (1);
  171. ADD_DEFAULT_CHARSET_UNSET = (2);
  172. {$ifdef CHARSET_EBCDIC}
  173. { Configurable EBCDIC Conversion stuff }
  174. { Direction specific conversion: }
  175. dir_Out = 0; { 0utput (returned contents in a GET or POST) }
  176. dir_In = 1; { 1nput (uploaded contents in a PUT / POST) }
  177. { Conversion Enabled/Disabled: }
  178. conv_Unset = '?'; { Conversion unconfigured }
  179. conv_Off = '0'; { BINARY or ASCII file (no conversion) }
  180. conv_On = '1'; { TEXT file (EBCDIC->ASCII for dir_Out; ASCII->EBCDIC for dir_In) }
  181. LEGACY_KLUDGE = 1; { After a couple of versions this legacy kludge should be set to 0 }
  182. ASCIITEXT_MAGIC_TYPE_PREFIX = 'text/x-ascii-'; { Text files whose content-type starts with this are passed thru unconverted }
  183. {$endif}
  184. type
  185. ap_flag_e = (
  186. AP_FLAG_UNSET = 0,
  187. AP_FLAG_ON = 1,
  188. AP_FLAG_OFF = 2
  189. );
  190. server_signature_t = ( srv_sig_unset, srv_sig_off, srv_sig_on,
  191. srv_sig_withmail);
  192. core_dir_config = record
  193. { path of the directory/regex/etc. see also d_is_fnmatch below }
  194. d: PChar;
  195. { the number of slashes in d }
  196. d_components: cuint;
  197. { If (opts & OPT_UNSET) then no absolute assignment to options has
  198. * been made.
  199. * invariant: (opts_add & opts_remove) == 0
  200. * Which said another way means that the last relative (options + or -)
  201. * assignment made to each bit is recorded in exactly one of opts_add
  202. * or opts_remove.
  203. }
  204. opts: allow_options_t;
  205. opts_add: allow_options_t;
  206. opts_remove: allow_options_t;
  207. override_: overrides_t;
  208. { MIME typing --- the core doesn't do anything at all with this,
  209. * but it does know what to slap on a request for a document which
  210. * goes untyped by other mechanisms before it slips out the door...
  211. }
  212. ap_default_type: PChar;
  213. { Authentication stuff. Groan... }
  214. satisfy: cint;
  215. ap_auth_type: PChar;
  216. ap_auth_name: PChar;
  217. ap_requires: Parray_header;
  218. { Custom response config. These can contain text or a URL to redirect to.
  219. * if response_code_strings is NULL then there are none in the config,
  220. * if it's not null then it's allocated to sizeof(char*)*RESPONSE_CODES.
  221. * This lets us do quick merges in merge_core_dir_configs().
  222. }
  223. response_code_strings: PPChar; { from ErrorDocument, not from
  224. * ap_custom_response()
  225. }
  226. { Hostname resolution etc }
  227. { Moved Up }
  228. // unsigned int hostname_lookups : 4;
  229. // signed int do_rfc1413 : 2; { See if client is advertising a username? }
  230. // signed int content_md5 : 2; { calculate Content-MD5? }
  231. { Moved Up }
  232. // unsigned use_canonical_name : 2;
  233. { since is_fnmatch(conf->d) was being called so frequently in
  234. * directory_walk() and its relatives, this field was created and
  235. * is set to the result of that call.
  236. }
  237. // unsigned d_is_fnmatch : 1;
  238. { should we force a charset on any outgoing parameterless content-type?
  239. * if so, which charset?
  240. }
  241. { Moved up }
  242. // unsigned add_default_charset : 2;
  243. add_default_charset_name: PChar;
  244. { System Resource Control }
  245. {$ifdef RLIMIT_CPU}
  246. limit_cpu: Prlimit;
  247. {$endif}
  248. {$if defined(RLIMIT_DATA) or defined(RLIMIT_VMEM) or defined(RLIMIT_AS)}
  249. limit_mem: Prlimit;
  250. {$endif}
  251. {$ifdef RLIMIT_NPROC}
  252. limit_nproc: Prlimit;
  253. {$endif}
  254. limit_req_body: culong; { limit on bytes in request msg body }
  255. { logging options }
  256. server_signature: server_signature_t;
  257. loglevel: cint;
  258. { Access control }
  259. sec: Parray_header;
  260. r: Pregex_t;
  261. {$ifdef WINDOWS}
  262. { Where to find interpreter to run scripts }
  263. script_interpreter_source: interpreter_source_e;
  264. {$endif}
  265. {$ifdef CHARSET_EBCDIC}
  266. { Moved up }
  267. { The configuration args {On|Off}[={In|Out|InOut}] are currently stored
  268. * as character strings ("0" = conv_Off, "1" = conv_On)
  269. }
  270. ebcdicconversion_by_ext_in: Ptable;
  271. ebcdicconversion_by_ext_out: Ptable;
  272. ebcdicconversion_by_type_in: Ptable;
  273. ebcdicconversion_by_type_out: Ptable;
  274. { Moved up }
  275. x_ascii_magic_kludge: cint; { whether to handle the text/x-ascii- kludge }
  276. {$ifdef ADD_EBCDICCONVERT_DEBUG_HEADER}
  277. ebcdicconversion_debug_header: cint; { whether to add an X-EBCDIC-Debug-{In,Out} header to the response }
  278. {$endif}
  279. {$endif} { CHARSET_EBCDIC }
  280. {
  281. * What attributes/data should be included in ETag generation?
  282. }
  283. etag_bits: etag_components_t;
  284. etag_add: etag_components_t;
  285. etag_remove: etag_components_t;
  286. {
  287. * Do we allow ISINDEX CGI scripts to pass their query argument as
  288. * direct command line parameters or argv elements?
  289. }
  290. cgi_command_args: ap_flag_e;
  291. { Digest auth. }
  292. ap_auth_nonce: PChar;
  293. end;
  294. { Per-server core configuration }
  295. type
  296. core_server_config = record
  297. {$ifdef GPROF}
  298. gprof_dir: PChar;
  299. {$endif}
  300. { Name translations --- we want the core to be able to do *something*
  301. * so it's at least a minimally functional web server on its own (and
  302. * can be tested that way). But let's keep it to the bare minimum:
  303. }
  304. ap_document_root: PChar;
  305. { Access control }
  306. access_name: PChar;
  307. sec: Parray_header;
  308. sec_url: Parray_header;
  309. { recursion backstopper }
  310. recursion_limit_set: cint; { boolean }
  311. redirect_limit: cint; { maximum number of internal redirects }
  312. subreq_limit: cint; { maximum nesting level of subrequests }
  313. { TRACE control }
  314. trace_enable: cint; { see AP_TRACE_ below }
  315. end;
  316. { trace_enable options }
  317. const
  318. AP_TRACE_UNSET =-1;
  319. AP_TRACE_DISABLE = 0;
  320. AP_TRACE_ENABLE = 1;
  321. AP_TRACE_EXTENDED = 2;
  322. { for http_config.c }
  323. //CORE_EXPORT(void) ap_core_reorder_directories(pool *, server_rec *);
  324. { for mod_perl }
  325. //CORE_EXPORT(void) ap_add_per_dir_conf (server_rec *s, void *dir_config);
  326. //CORE_EXPORT(void) ap_add_per_url_conf (server_rec *s, void *url_config);
  327. //CORE_EXPORT(void) ap_add_file_conf(core_dir_config *conf, void *url_config);
  328. //CORE_EXPORT_NONSTD(const char *) ap_limit_section (cmd_parms *cmd, void *dummy, const char *arg);
  329. {.$endif}