From: Stefan Fritsch Date: Sat, 17 Nov 2012 17:43:33 +0000 (+0000) Subject: Add SERVER_PROTOCOL_VERSION, SERVER_PROTOCOL_VERSION_MAJOR, X-Git-Tag: 2.5.0-alpha~6108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aad88eb93f4745da844187dfbf465bba98f0a2e;p=thirdparty%2Fapache%2Fhttpd.git Add SERVER_PROTOCOL_VERSION, SERVER_PROTOCOL_VERSION_MAJOR, 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 --- diff --git a/CHANGES b/CHANGES index 1dfb0837358..c12c51bdf5f 100644 --- 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] diff --git a/docs/manual/expr.xml b/docs/manual/expr.xml index 41bf6462b9e..c3252c21a26 100644 --- a/docs/manual/expr.xml +++ b/docs/manual/expr.xml @@ -220,7 +220,20 @@ listfunction ::= listfuncname "(" word ")" The ServerAdmin of the current vhost SERVER_PROTOCOL - The protocol used by the request + The protocol used by the request (e.g. HTTP/1.1). In some types of + internal subrequests, this variable has the value + INCLUDED. + SERVER_PROTOCOL_VERSION + A number that encodes the HTTP version of the request: + 1000 * major + minor. For example, 1001 + corresponds to HTTP/1.1 and 9 corresponds + to HTTP/0.9 + SERVER_PROTOCOL_VERSION_MAJOR + A major version part of the HTTP version of the request, + e.g. 1 for HTTP/1.0 + SERVER_PROTOCOL_VERSION_MINOR + A minor version part of the HTTP version of the request, + e.g. 0 for HTTP/1.0 DOCUMENT_ROOT The DocumentRoot of the current vhost diff --git a/server/util_expr_eval.c b/server/util_expr_eval.c index b350cfc7716..56035dc84c2 100644 --- a/server/util_expr_eval.c +++ b/server/util_expr_eval.c @@ -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;