You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by sf...@apache.org on 2012/11/17 18:43:34 UTC

svn commit: r1410755 - in /httpd/httpd/trunk: CHANGES docs/manual/expr.xml server/util_expr_eval.c

Author: sf
Date: Sat Nov 17 17:43:33 2012
New Revision: 1410755

URL: http://svn.apache.org/viewvc?rev=1410755&view=rev
Log:
Add SERVER_PROTOCOL_VERSION, SERVER_PROTOCOL_VERSION_MAJOR,
SERVER_PROTOCOL_VERSION_MINOR ap_expr variables.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/expr.xml
    httpd/httpd/trunk/server/util_expr_eval.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1410755&r1=1410754&r2=1410755&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Sat Nov 17 17:43:33 2012
@@ -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]

Modified: httpd/httpd/trunk/docs/manual/expr.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/expr.xml?rev=1410755&r1=1410754&r2=1410755&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/expr.xml (original)
+++ httpd/httpd/trunk/docs/manual/expr.xml Sat Nov 17 17:43:33 2012
@@ -220,7 +220,20 @@ listfunction ::= listfuncname "<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>

Modified: httpd/httpd/trunk/server/util_expr_eval.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_expr_eval.c?rev=1410755&r1=1410754&r2=1410755&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_expr_eval.c (original)
+++ httpd/httpd/trunk/server/util_expr_eval.c Sat Nov 17 17:43:33 2012
@@ -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_exp
         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;