diff options
author | Jim Jagielski <jim@apache.org> | 2022-08-28 20:46:21 +0200 |
---|---|---|
committer | Jim Jagielski <jim@apache.org> | 2022-08-28 20:46:21 +0200 |
commit | eb2325b1254bfaf341dd8e6e6a18bec61733bf69 (patch) | |
tree | 3b706a7a32e61105696ccee80f053df2363b8de7 /modules | |
parent | fr doc rebuild. (diff) | |
download | apache2-eb2325b1254bfaf341dd8e6e6a18bec61733bf69.tar.xz apache2-eb2325b1254bfaf341dd8e6e6a18bec61733bf69.zip |
Allow for HTTP/1.1 or HTTP/1.0 protocol health checks
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1903744 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r-- | modules/proxy/mod_proxy.c | 3 | ||||
-rw-r--r-- | modules/proxy/mod_proxy.h | 2 | ||||
-rw-r--r-- | modules/proxy/mod_proxy_hcheck.c | 34 |
3 files changed, 29 insertions, 10 deletions
diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 27f3118578..3c36f03991 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -52,6 +52,9 @@ proxy_hcmethods_t PROXY_DECLARE_DATA proxy_hcmethods[] = { {GET, "GET", 1}, {CPING, "CPING", 0}, {PROVIDER, "PROVIDER", 0}, + {OPTIONS11, "OPTIONS11", 1}, + {HEAD11, "HEAD11", 1}, + {GET11, "GET11", 1}, {EOT, NULL, 1} }; diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 6301845712..c15d0785c3 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -77,7 +77,7 @@ enum enctype { }; typedef enum { - NONE, TCP, OPTIONS, HEAD, GET, CPING, PROVIDER, EOT + NONE, TCP, OPTIONS, HEAD, GET, CPING, PROVIDER, OPTIONS11, HEAD11, GET11, EOT } hcmethod_t; typedef struct { diff --git a/modules/proxy/mod_proxy_hcheck.c b/modules/proxy/mod_proxy_hcheck.c index 88723ba676..637af645ea 100644 --- a/modules/proxy/mod_proxy_hcheck.c +++ b/modules/proxy/mod_proxy_hcheck.c @@ -65,6 +65,7 @@ typedef struct { const char *method; /* Method string for the HTTP/AJP request */ const char *req; /* pre-formatted HTTP/AJP request */ proxy_worker *w; /* Pointer to the actual worker */ + const char *protocol; /* HTTP 1.0 or 1.1? */ } wctx_t; typedef struct { @@ -342,7 +343,8 @@ static const char *set_hc_tpsize (cmd_parms *cmd, void *dummy, const char *arg) */ static request_rec *create_request_rec(apr_pool_t *p, server_rec *s, proxy_balancer *balancer, - const char *method) + const char *method, + const char *protocol) { request_rec *r; @@ -400,10 +402,12 @@ static request_rec *create_request_rec(apr_pool_t *p, server_rec *s, else { r->header_only = 0; } - r->protocol = "HTTP/1.0"; r->proto_num = HTTP_VERSION(1, 0); - + if ( protocol && (protocol[7] == '1') ) { + r->protocol = "HTTP/1.1"; + r->proto_num = HTTP_VERSION(1, 1); + } r->hostname = NULL; return r; @@ -427,28 +431,39 @@ static void create_hcheck_req(wctx_t *wctx, proxy_worker *hc, { char *req = NULL; const char *method = NULL; + const char *protocol = NULL; + + /* TODO: Fold into switch/case below? This seems more obvious */ + if ( (hc->s->method == OPTIONS11) || (hc->s->method == HEAD11) || (hc->s->method == GET11) ) { + protocol = "HTTP/1.1"; + } else { + protocol = "HTTP/1.0"; + } switch (hc->s->method) { case OPTIONS: + case OPTIONS11: method = "OPTIONS"; req = apr_psprintf(p, - "OPTIONS * HTTP/1.0\r\n" + "OPTIONS * %s\r\n" "Host: %s:%d\r\n" - "\r\n", + "\r\n", protocol, hc->s->hostname_ex, (int)hc->s->port); break; case HEAD: + case HEAD11: method = "HEAD"; /* fallthru */ case GET: + case GET11: if (!method) { /* did we fall thru? If not, we are GET */ method = "GET"; } req = apr_psprintf(p, - "%s %s%s%s HTTP/1.0\r\n" + "%s %s%s%s %s\r\n" "Host: %s:%d\r\n" "\r\n", - method, + method, protocol, (wctx->path ? wctx->path : ""), (wctx->path && *hc->s->hcuri ? "/" : "" ), (*hc->s->hcuri ? hc->s->hcuri : ""), @@ -460,6 +475,7 @@ static void create_hcheck_req(wctx_t *wctx, proxy_worker *hc, } wctx->req = req; wctx->method = method; + wctx->protocol = protocol; } static proxy_worker *hc_get_hcworker(sctx_t *ctx, proxy_worker *worker, @@ -639,7 +655,7 @@ static apr_status_t hc_check_cping(baton_t *baton, apr_thread_t *thread) if ((status = ap_proxy_connect_backend("HCCPING", backend, hc, ctx->s)) != OK) { return backend_cleanup("HCCPING", backend, ctx->s, status); } - r = create_request_rec(ptemp, ctx->s, baton->balancer, "CPING"); + r = create_request_rec(ptemp, ctx->s, baton->balancer, "CPING", NULL); if ((status = ap_proxy_connection_create_ex("HCCPING", backend, r)) != OK) { return backend_cleanup("HCCPING", backend, ctx->s, status); } @@ -826,7 +842,7 @@ static apr_status_t hc_check_http(baton_t *baton, apr_thread_t *thread) return backend_cleanup("HCOH", backend, ctx->s, status); } - r = create_request_rec(ptemp, ctx->s, baton->balancer, wctx->method); + r = create_request_rec(ptemp, ctx->s, baton->balancer, wctx->method, wctx->protocol); if ((status = ap_proxy_connection_create_ex("HCOH", backend, r)) != OK) { return backend_cleanup("HCOH", backend, ctx->s, status); } |