httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jens Frey <jens.f...@coffeecrew.org>
Subject Run Subrequest
Date Thu, 15 Oct 2009 08:14:40 GMT
Hi all,

i am trying to run a subrequest to a URI which get's proxied to check the return code of the

machine the proxy points to (e.g. 200, 500). The problem now is that the proxy module answers
the request,
but the content i want to send is omitted, so the question is, how can i avoid that mod_proxy

responds and instead my response is written, any ideas?

E.g. setup

httpd.conf
ProxyPass /checkHere http://localhost:8080/checkThere

---

code:
if (ap_is_initial_req(r)) {
        
        requestURI = apr_pstrcat(r->pool, REQUEST_URI_BASE, "?code=200", NULL);
        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 
                      0, r, 
                      "Have built URI %s", requestURI);
        rr = ap_sub_req_method_uri("GET", requestURI, r, NULL);
        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 
                      sub_req_return_code, r, 
                      "Looked up URI");

        sub_req_return_code = ap_run_sub_req(rr);
        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 
                      0, r, 
                      "Did run subrequest");

        tmp = apr_psprintf(r->pool, "%d", sub_req_return_code);
        response_body = apr_pstrcat(r->pool, response_body, "Did run call to ", requestURI,
" have result code ", tmp, NULL);

        ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 
                      sub_req_return_code, rr, 
                      "Subrequesting URI finished with code: %d", sub_req_return_code);
        
    } else {
        return DECLINED;
    }

    if (!r->header_only) {
        ap_rputs(response_start, r);
        ap_rputs(response_body, r);
        ap_rputs(response_end, r);
    }
    return OK;

Thanks,
Jens

Mime
View raw message