httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Wortham" <>
Subject 'POST SubRequest via mod_proxy' Question
Date Wed, 07 Mar 2007 19:28:48 GMT
Hello again developers,
    I don't fully expect anyone to be able to answer this question.  At this
point, I am just looking for ideas to try.

   I am still trying to get my module to make a POST request to an external
server (I am using a subrequest that bounces off of mod_proxy to the
external server).  I have successfully created a subrequest using a "POST"
method, but:
(1) I can't seem to get the content of the POST (the post variables) written
to the subrequest body; I have tried a 'ap_rprintf(...)', but it appears
that the contents of this write becomes the beginning of the response
(2) Is the content of a subrequest expected to output directly to the

    int status code

    if(is_request_a_honeypot_token(r) && string_matches(r->method, "GET"))
        int             status_code = OK;
        request_rec*    subr        = NULL;
        char            newurl[2048];
//        apr_snprintf(newurl, sizeof(newurl), "proxy:%s://%s:%d/%s",
"http", "", 11000, "cgi/serve.php");
        apr_snprintf(newurl, sizeof(newurl), "proxy:%s://%s:%d/%s", "http",
"", 18000, "raw.html");
#if IS_DEBUG_MODE == 1
    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "HTTPBL: Handling Honeypot
    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "HTTPBL: New POST Request
URI: %s", newurl);
    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "HTTPBL: POST Request
Parameters: %s", newparams);

        if (ap_find_linked_module("mod_proxy.c") == NULL)
            status = HTTP_INTERNAL_SERVER_ERROR;
            ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Access denied with
code 500%s "
                         "(Internal Error: proxy action to %s requested but
mod_proxy not found).",
            return status;
#if IS_DEBUG_MODE == 1
    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "HTTPBL: mod_proxy module
found successfully");
            // Make a subrequest to mod_proxy, POSTing to the Honeypot
server and passing the resulting content as the content of the SuperRequest
            subr    = (request_rec*)ap_sub_req_method_uri("POST", "*", r,
NULL); // this MUST succeed!
            subr->assbackwards = 0;

            //    build POST headers
            char    postparams[8192];
            apr_snprintf(postparams, sizeof(postparams),
            ap_set_content_type(subr, "application/x-www-form-urlencoded");
            apr_table_set(subr->headers_in, "Content-Length",
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "query constructed: %s
(%s)", newurl, postparams);
            ap_rprintf(subr, "%s", postparams);
            subr->filename = apr_pstrdup(r->pool, newurl);
            subr->proxyreq = PROXYREQ_REVERSE;
            subr->handler = "proxy-server";
            status_code = ap_run_sub_req(subr);

#if IS_DEBUG_MODE == 1
    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "HTTPBL: Honeypot Response:
status code(%d)", status_code);
    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "HTTPBL: Honeypot Response:
hostname - \"%s\"", subr->hostname);
    ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "HTTPBL: Honeypot Response:
method   - \"%s\"", subr->method);

            if (status_code == 200)
                // write from the subrequest results to the SuperRequest
                ap_set_content_type(r, "text/html");
                int bytes_sent  = ap_rprintf(r, "<html>\n\t<head>\n<title>MY
FIRST HONEYPOT</title>\n\t</head>\n\t<body>\n\t\t<h1>My First
// done processing content

            status = OK;

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message