]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Add SERVER_PROTOCOL_VERSION, SERVER_PROTOCOL_VERSION_MAJOR,
authorStefan Fritsch <sf@apache.org>
Sat, 17 Nov 2012 17:43:33 +0000 (17:43 +0000)
committerStefan Fritsch <sf@apache.org>
Sat, 17 Nov 2012 17:43:33 +0000 (17:43 +0000)
SERVER_PROTOCOL_VERSION_MINOR ap_expr variables.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1410755 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
docs/manual/expr.xml
server/util_expr_eval.c

diff --git a/CHANGES b/CHANGES
index 1dfb0837358caf3ee8d2d074d46765c6423ddbbc..c12c51bdf5f71480ccc050ec8e1a7f9f0c68e441 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) ap_expr: Add SERVER_PROTOCOL_VERSION, ..._MAJOR, and ..._MINOR
+     variables. [Stefan Fritsch]
+
   *) mod_rewrite: Stop mergeing RewriteBase down to subdirectories
      unless new option 'RewriteOptions MergeBase' is configured.
      PR 53963. [Eric Covener]
index 41bf6462b9e3cdb76f227bdb367bde2f7f703d81..c3252c21a267ff19199d51c2042b05cafc35d61d 100644 (file)
@@ -220,7 +220,20 @@ listfunction ::= listfuncname "<strong>(</strong>" word "<strong>)</strong>"
         <td>The <directive module="core">ServerAdmin</directive> of
             the current vhost</td></tr>
     <tr><td><code>SERVER_PROTOCOL</code></td>
-        <td>The protocol used by the request</td></tr>
+        <td>The protocol used by the request (e.g. HTTP/1.1). In some types of
+            internal subrequests, this variable has the value
+            <code>INCLUDED</code>.</td></tr>
+    <tr><td><code>SERVER_PROTOCOL_VERSION</code></td>
+        <td>A number that encodes the HTTP version of the request:
+            <code>1000 * major + minor</code>. For example, <code>1001</code>
+            corresponds to HTTP/1.1 and <code>9</code> corresponds
+            to HTTP/0.9</td></tr>
+    <tr><td><code>SERVER_PROTOCOL_VERSION_MAJOR</code></td>
+        <td>A major version part of the HTTP version of the request,
+            e.g. <code>1</code> for HTTP/1.0</td></tr>
+    <tr><td><code>SERVER_PROTOCOL_VERSION_MINOR</code></td>
+        <td>A minor version part of the HTTP version of the request,
+            e.g. <code>0</code> for HTTP/1.0</td></tr>
     <tr><td><code>DOCUMENT_ROOT</code></td>
         <td>The <directive module="core">DocumentRoot</directive> of
             the current vhost</td></tr>
index b350cfc7716d9e823aadff9bf04775f7abf564ba..56035dc84c240f32ca60c21e39f671ac4fbfe86b 100644 (file)
@@ -1262,6 +1262,9 @@ static const char *request_var_names[] = {
     "CONTEXT_DOCUMENT_ROOT",    /* 26 */
     "REQUEST_STATUS",           /* 27 */
     "REMOTE_ADDR",              /* 28 */
+    "SERVER_PROTOCOL_VERSION",  /* 29 */
+    "SERVER_PROTOCOL_VERSION_MAJOR",  /* 30 */
+    "SERVER_PROTOCOL_VERSION_MINOR",  /* 31 */
     NULL
 };
 
@@ -1349,6 +1352,26 @@ static const char *request_var_fn(ap_expr_eval_ctx_t *ctx, const void *data)
         return r->status ? apr_psprintf(ctx->p, "%d", r->status) : "";
     case 28:
         return r->useragent_ip;
+    case 29:
+        switch (r->proto_num) {
+        case 1001:  return "1001";   /* 1.1 */
+        case 1000:  return "1000";   /* 1.0 */
+        case 9:     return "9";      /* 0.9 */
+        }
+        return apr_psprintf(ctx->p, "%d", r->proto_num);
+    case 30:
+        switch (HTTP_VERSION_MAJOR(r->proto_num)) {
+        case 0:     return "0";
+        case 1:     return "1";
+        }
+        return apr_psprintf(ctx->p, "%d", HTTP_VERSION_MAJOR(r->proto_num));
+    case 31:
+        switch (HTTP_VERSION_MINOR(r->proto_num)) {
+        case 0:     return "0";
+        case 1:     return "1";
+        case 9:     return "9";
+        }
+        return apr_psprintf(ctx->p, "%d", HTTP_VERSION_MINOR(r->proto_num));
     default:
         ap_assert(0);
         return NULL;