MCPcopy Create free account
hub / github.com/apache/httpd / hc_check_http

Function hc_check_http

modules/proxy/mod_proxy_hcheck.c:841–919  ·  view source on GitHub ↗

* Send the HTTP OPTIONS, HEAD or GET request to the backend * server associated w/ worker. If we have Conditions, * then apply those to the resulting response, otherwise * any status code 2xx or 3xx is considered "passing" */

Source from the content-addressed store, hash-verified

839 * any status code 2xx or 3xx is considered "passing"
840 */
841static apr_status_t hc_check_http(baton_t *baton, apr_thread_t *thread)
842{
843 int status;
844 proxy_conn_rec *backend = NULL;
845 sctx_t *ctx = baton->ctx;
846 proxy_worker *hc = baton->hc;
847 proxy_worker *worker = baton->worker;
848 apr_pool_t *ptemp = baton->ptemp;
849 request_rec *r;
850 wctx_t *wctx;
851 hc_condition_t *cond;
852 apr_bucket_brigade *bb;
853
854 wctx = (wctx_t *)hc->context;
855 if (!wctx->req || !wctx->method) {
856 return APR_ENOTIMPL;
857 }
858
859 if ((status = hc_get_backend("HCOH", &backend, hc, ctx)) != OK) {
860 return backend_cleanup("HCOH", backend, ctx->s, status);
861 }
862 if ((status = ap_proxy_connect_backend("HCOH", backend, hc, ctx->s)) != OK) {
863 return backend_cleanup("HCOH", backend, ctx->s, status);
864 }
865
866 r = create_request_rec(ptemp, ctx->s, baton->balancer, wctx->method, wctx->protocol);
867 if ((status = ap_proxy_connection_create_ex("HCOH", backend, r)) != OK) {
868 return backend_cleanup("HCOH", backend, ctx->s, status);
869 }
870 set_request_connection(r, backend->connection);
871 backend->connection->current_thread = thread;
872
873 bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
874
875 if ((status = hc_send(r, wctx->req, bb)) != OK) {
876 return backend_cleanup("HCOH", backend, ctx->s, status);
877 }
878 if ((status = hc_read_headers(r)) != OK) {
879 return backend_cleanup("HCOH", backend, ctx->s, status);
880 }
881 if (!r->header_only) {
882 apr_table_t *saved_headers_in = r->headers_in;
883 r->headers_in = apr_table_copy(r->pool, r->headers_out);
884 ap_proxy_pre_http_request(backend->connection, r);
885 status = hc_read_body(r, bb);
886 r->headers_in = saved_headers_in;
887 if (status != OK) {
888 return backend_cleanup("HCOH", backend, ctx->s, status);
889 }
890 r->trailers_out = apr_table_copy(r->pool, r->trailers_in);
891 }
892
893 if (*worker->s->hcexpr &&
894 (cond = (hc_condition_t *)apr_table_get(ctx->conditions, worker->s->hcexpr)) != NULL) {
895 const char *err;
896 int ok = ap_expr_exec(r, cond->pexpr, &err);
897 if (ok > 0) {
898 ap_log_error(APLOG_MARK, APLOG_TRACE2, 0, ctx->s,

Callers 1

hc_checkFunction · 0.85

Calls 12

hc_get_backendFunction · 0.85
backend_cleanupFunction · 0.85
ap_proxy_connect_backendFunction · 0.85
create_request_recFunction · 0.85
set_request_connectionFunction · 0.85
hc_sendFunction · 0.85
hc_read_headersFunction · 0.85
hc_read_bodyFunction · 0.85
ap_expr_execFunction · 0.85
ap_log_errorFunction · 0.50

Tested by

no test coverage detected