Return-Path: X-Original-To: apmail-httpd-dev-archive@www.apache.org Delivered-To: apmail-httpd-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5E5F01823F for ; Thu, 21 Jan 2016 18:06:58 +0000 (UTC) Received: (qmail 59390 invoked by uid 500); 21 Jan 2016 18:06:57 -0000 Delivered-To: apmail-httpd-dev-archive@httpd.apache.org Received: (qmail 59316 invoked by uid 500); 21 Jan 2016 18:06:57 -0000 Mailing-List: contact dev-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@httpd.apache.org Received: (qmail 59245 invoked by uid 99); 21 Jan 2016 18:06:57 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 21 Jan 2016 18:06:57 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 7AFE7180519 for ; Thu, 21 Jan 2016 18:06:57 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.555 X-Spam-Level: X-Spam-Status: No, score=-0.555 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.554, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id sVijgbDBKgko for ; Thu, 21 Jan 2016 18:06:55 +0000 (UTC) Received: from mailserver.kippdata.de (capsella.kippdata.de [195.227.30.149]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTP id CC91723016 for ; Thu, 21 Jan 2016 18:06:54 +0000 (UTC) Received: from [10.0.110.6] ([192.168.2.104]) by mailserver.kippdata.de (8.13.5/8.13.5) with ESMTP id u0LI6roL004751 for ; Thu, 21 Jan 2016 19:06:54 +0100 (CET) Subject: Re: svn commit: r1726038 - /httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c To: dev@httpd.apache.org References: <20160121174922.32B953A01D9@svn01-us-west.apache.org> <852C03FD-5797-4517-8A40-D51A34F494AB@jaguNET.com> From: Rainer Jung Message-ID: <56A11E39.7060101@kippdata.de> Date: Thu, 21 Jan 2016 19:06:49 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-Version: 1.0 In-Reply-To: <852C03FD-5797-4517-8A40-D51A34F494AB@jaguNET.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Am 21.01.2016 um 18:55 schrieb Jim Jagielski: > This implies that the kept_body() func added to ap_expr should > be removed, right? At least it is no longer needed for proxy_hcheck. If we want to provide the original kept_body as used by mod_request to expr we can keep it. I don't know whether such use is sensible, but maybe best at this point to remove it after you can confirm the new approach works for you. Regards, Rainer >> On Jan 21, 2016, at 12:49 PM, rjung@apache.org wrote: >> >> Author: rjung >> Date: Thu Jan 21 17:49:21 2016 >> New Revision: 1726038 >> >> URL: http://svn.apache.org/viewvc?rev=1726038&view=rev >> Log: >> Implement expr lookup in mod_proxy_hcheck for >> variables whose names start with "HC_" and for >> the new function hc(). >> >> Currently only HC_BODY and hc(body) are supported. >> Both return the saved body of the health check >> response to be used in an expr that decides about >> success of a check. >> >> Modified: >> httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c >> >> Modified: httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c >> URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c?rev=1726038&r1=1726037&r2=1726038&view=diff >> ============================================================================== >> --- httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c (original) >> +++ httpd/httpd/trunk/modules/proxy/mod_proxy_hcheck.c Thu Jan 21 17:49:21 2016 >> @@ -926,6 +926,75 @@ static void hc_show_exprs(request_rec *r >> ap_rputs("
\n", r); >> } >> >> +static const char *hc_get_body(request_rec *r) >> +{ >> + apr_off_t length; >> + apr_size_t len; >> + apr_status_t rv; >> + char *buf; >> + >> + if (!r || !r->kept_body) >> + return ""; >> + >> + rv = apr_brigade_length(r->kept_body, 1, &length); >> + len = (apr_size_t)length; >> + if (rv != APR_SUCCESS || len == 0) >> + return ""; >> + >> + buf = apr_palloc(r->pool, len + 1); >> + rv = apr_brigade_flatten(r->kept_body, buf, &len); >> + if (rv != APR_SUCCESS) >> + return ""; >> + buf[len] = '\0'; /* ensure */ >> + return (const char*)buf; >> +} >> + >> +static const char *hc_expr_var_fn(ap_expr_eval_ctx_t *ctx, const void *data) >> +{ >> + char *var = (char *)data; >> + >> + if (var && *var && ctx->r && ap_casecmpstr(var, "BODY") == 0) { >> + return hc_get_body(ctx->r); >> + } >> + return NULL; >> +} >> + >> +static const char *hc_expr_func_fn(ap_expr_eval_ctx_t *ctx, const void *data, >> + const char *arg) >> +{ >> + char *var = (char *)arg; >> + >> + if (var && *var && ctx->r && ap_casecmpstr(var, "BODY") == 0) { >> + return hc_get_body(ctx->r); >> + } >> + return NULL; >> +} >> + >> +static int hc_expr_lookup(ap_expr_lookup_parms *parms) >> +{ >> + switch (parms->type) { >> + case AP_EXPR_FUNC_VAR: >> + /* for now, we just handle everything that starts with HC_. >> + */ >> + if (strncasecmp(parms->name, "HC_", 3) == 0) { >> + *parms->func = hc_expr_var_fn; >> + *parms->data = parms->name + 4; >> + return OK; >> + } >> + break; >> + case AP_EXPR_FUNC_STRING: >> + /* Function HC() is implemented by us. >> + */ >> + if (strcasecmp(parms->name, "HC") == 0) { >> + *parms->func = hc_expr_func_fn; >> + *parms->data = NULL; >> + return OK; >> + } >> + break; >> + } >> + return DECLINED; >> +} >> + >> static const command_rec command_table[] = { >> AP_INIT_RAW_ARGS("ProxyHCTemplate", set_hc_template, NULL, OR_FILEINFO, >> "Health check template"), >> @@ -941,6 +1010,7 @@ static void hc_register_hooks(apr_pool_t >> APR_REGISTER_OPTIONAL_FN(set_worker_hc_param); >> APR_REGISTER_OPTIONAL_FN(hc_show_exprs); >> ap_hook_post_config(hc_post_config, aszPre, aszSucc, APR_HOOK_LAST); >> + ap_hook_expr_lookup(hc_expr_lookup, NULL, NULL, APR_HOOK_MIDDLE); >> } >> >> /* the main config structure */