Commit a4592974 authored by Joe Orton's avatar Joe Orton
Browse files

Add <IfDirective> and <IfSection>:

* server/core.c
  (test_ifdirective_section, test_ifsection_section): New callbacks.
  (core_cmds): Define new directives.

* include/http_config.h, server/config.c (ap_exists_directive):
  New function.

* include/ap_mmn.h: Bump MMN minor for above.

* docs/manual/mod/core.xml: Add docs.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1786110 13f79535-47bb-0310-9956-ffa450edef68
parent 00d23f74
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
                                                         -*- coding: utf-8 -*-
Changes with Apache 2.5.0

  *) Add <IfDirective> and <IfSection> directives.  [Joe Orton]

  *) mod_http2: stream timeouts now change to vhost values once the request
     is parsed and processing starts. Initial values are taken from base
     server or SNI host as before. [Stefan Eissing]
+108 −6
Original line number Diff line number Diff line
@@ -788,12 +788,12 @@ DefaultType None
</contextlist>

<usage>
    <p>In its one parameter form, <directive>Define</directive> is equivalent
    to passing the <code>-D</code> argument to <program>httpd</program>. It
    can be used to toggle the use of
    <directive module="core" type="section">IfDefine</directive> sections
    without needing to alter <code>-D</code> arguments in any startup
    scripts.</p>
    <p>In its one parameter form, <directive>Define</directive> is
    equivalent to passing the <code>-D</code> argument to
    <program>httpd</program>. It can be used to toggle the use of
    <directive module="core" type="section">IfDefine</directive>
    sections without needing to alter <code>-D</code> arguments in any
    startup scripts.</p>

    <p>In addition to that, if the second parameter is given, a config variable
    is set to this value. The variable can be used in the configuration using
@@ -2389,6 +2389,108 @@ presence or absence of a specific module</description>
</usage>
</directivesynopsis>

<directivesynopsis type="section">
<name>IfDirective</name>
<description>Encloses directives that are processed conditional on the
presence or absence of a specific directive</description>
<syntax>&lt;IfDirective [!]<var>directive-name</var>&gt; ...
    &lt;/IfDirective&gt;</syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context>
</contextlist>
<override>All</override>

<usage>
    <p>The <code>&lt;IfDirective <var>test</var>&gt;...&lt;/IfDirective&gt;</code>
    section is used to mark directives that are conditional on the presence of
    a specific directive. The directives within an <directive type="section"
    >IfDirective</directive> section are only processed if the <var>test</var>
    is true. If <var>test</var> is false, everything between the start and
    end markers is ignored.</p>

    <p>The <var>test</var> in the <directive type="section"
    >IfDirective</directive> section can be one of two forms:</p>

    <ul>
      <li><var>directive-name</var></li>

      <li>!<var>directive-name</var></li>
    </ul>

    <p>In the former case, the directives between the start and end
    markers are only processed if a directive of the given name is
    available at the time of processing.  The second format reverses the test,
    and only processes the directives if the <var>directive-name</var> is
    <strong>not</strong> defined.</p>

    <note>This section should only be used if you need to have one
    configuration file that works across multiple versions of
    <program>httpd</program>, regardless of whether a particular
    directive is available. In normal operation, directives need not
    be placed in <directive type="section">IfDirective</directive>
    sections.</note>
</usage>
<seealso><directive module="core" type="section">IfSection</directive></seealso>
</directivesynopsis>

<directivesynopsis type="section">
<name>IfSection</name>
<description>Encloses directives that are processed conditional on the
presence or absence of a specific section directive</description>
<syntax>&lt;IfSection [!]<var>section-name</var>&gt; ...
    &lt;/IfSection&gt;</syntax>
<contextlist><context>server config</context><context>virtual host</context>
<context>directory</context><context>.htaccess</context>
</contextlist>
<override>All</override>

<usage>
    <p>The <code>&lt;IfSection
    <var>test</var>&gt;...&lt;/IfSection&gt;</code> section is used
    to mark directives that are conditional on the presence of a
    specific section directive.  A section directive is any directive
    such as <directive type="section">virtualhost</directive> which
    encloses other directives, and has a directive name with a leading
    "&lt;".  The sec

    The directives within an <directive type="section"
    >IfSection</directive> section are only processed if the <var>test</var>
    is true. If <var>test</var> is false, everything between the start and
    end markers is ignored.</p>

    <p>The <var>section-name</var> specified must not include the
    leading "&lt;".  The <var>test</var> in the <directive
    type="section">IfSection</directive> section can be one of two
    forms:</p>

    <ul>
      <li><var>section-name</var></li>
      <li>!<var>section-name</var></li>
    </ul>

    <p>In the former case, the directives between the start and
    end markers are only processed if a section directive of the given
    name is available at the time of processing.  The second format
    reverses the test, and only processes the directives if the
    <var>section-name</var> is <strong>not</strong> defined.</p>

    <p>For example:</p>

    <highlight language="config">
&lt;IfSection VirtualHost&gt;
   ...
&lt;/IfSection&gt;
    </highlight>
    
    <note>This section should only be used if you need to have one
    configuration file that works across multiple versions of <program>httpd</program>,
    regardless of whether a particular section directive is
    available. In normal operation, directives need not be placed in
    <directive type="section">IfSection</directive> sections.</note>
</usage>
<seealso><directive module="core" type="section">IfDirective</directive></seealso>
</directivesynopsis>

<directivesynopsis>
<name>Include</name>
<description>Includes other configuration files from within
+2 −1
Original line number Diff line number Diff line
@@ -550,6 +550,7 @@
 *                         ap_get_http_token() and http_stricturi conf member.
 *                         Added ap_scan_vchar_obstext()
 * 20161018.2 (2.5.0-dev)  add ap_set_conn_count()
 * 20161018.3 (2.5.0-dev)  add ap_exists_directive()
 */

#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
@@ -557,7 +558,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20161018
#endif
#define MODULE_MAGIC_NUMBER_MINOR 2                 /* 0...n */
#define MODULE_MAGIC_NUMBER_MINOR 3                 /* 0...n */

/**
 * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
+8 −0
Original line number Diff line number Diff line
@@ -991,6 +991,14 @@ AP_DECLARE(const char *) ap_setup_prelinked_modules(process_rec *process);
 */
AP_DECLARE(void) ap_show_directives(void);

/**
 * Returns non-zero if a configuration directive of the given name has
 * been registered by a module at the time of calling.
 * @param p Pool for temporary allocations
 * @param name Directive name
 */
AP_DECLARE(int) ap_exists_directive(apr_pool_t *p, const char *name);

/**
 * Show the preloaded module names.  Used for httpd -l.
 */
+10 −0
Original line number Diff line number Diff line
@@ -2668,6 +2668,16 @@ AP_DECLARE(void) ap_show_modules(void)
        printf("  %s\n", ap_loaded_modules[n]->name);
}

AP_DECLARE(int) ap_exists_directive(apr_pool_t *p, const char *name)
{
    char *lname = apr_pstrdup(p, name);

    ap_str_tolower(lname);
    
    return ap_config_hash &&
        apr_hash_get(ap_config_hash, lname, APR_HASH_KEY_STRING) != NULL;
}

AP_DECLARE(void *) ap_retained_data_get(const char *key)
{
    void *retained;
Loading