httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Petr Hracek <phrac...@gmail.com>
Subject Re: Data are send in reverse order
Date Wed, 16 Sep 2009 12:07:10 GMT
In my module I do not modify any data sended from server to client.
Unfortunatelly when I am using ap_r* then firstly are sended data and then
HTTP relevant code.

Sample code is:
/*
 * Procedure for sending data from server to client side
 * Instead of ap_rvputs like functions should be used following procedure
 * especially for SecMCJ issue
 */
apr_status_t send_data_to_client(request_rec *r, char * data_to_send, int
length_data)
{
    //apr_status_t rv;
    apr_bucket_brigade * bb =
apr_brigade_create(r->pool,r->connection->bucket_alloc);
    apr_bucket * b =
apr_bucket_immortal_create(data_to_send,length_data,r->connection->bucket_alloc);
    APR_BRIGADE_INSERT_TAIL(bb,b);
    ap_pass_brigade(r->connection->output_filters,bb);
    //apr_bucket_destroy(b);
    //apr_brigade_destroy(bb);
    return OK;
}


/*
 * <Location /USSW/secmcj>
 *     SetHandler ussw-secmcj
 *     allow from all
 *     Satisfy any
 * </Location>
 */

int udsc_secmcj_handler(request_rec *r)
{
    secmcj_body = apr_pstrcat(r->pool,
              "sessionID=",
                  apr_psprintf(r->pool, "%lu", pSession->us.udsc_sessionid),
              "&requestNr=", pSession->session_id,
              *request_body == '&' ? "" : "&",
              request_body,
              NULL);
    /* now post the data to usmw /secmcj */
    ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r->server,
"secmcj body: %s",secmcj_body);

    /* now return the response to the client (secmcj class) */
    ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r->server,
"secmcj body receive: %s",response_body);

    r->content_type = "text/plain";

    /* added because of JRE 1.4 SE SSL problem */
    bodylen = strlen(response_body);
    ap_set_content_length(r, bodylen);


ap_send_http_header(r);

    if (r->header_only)
    {
        ap_log_error(APLOG_MARK,APLOG_NOERRNO | APLOG_DEBUG, 0, r->server,
"HEADER ONLY");
        return OK;
    }

    ap_log_error(APLOG_MARK, APLOG_NOERRNO | APLOG_DEBUG, 0, r->server,
"before any sending. Length is:%d",bodylen);
        send_data_to_client(r,response_body, bodylen);
    return OK;
}


best regards
Petr
Nick Kew napsal(a):

> Petr Hracek wrote:
>
>> I have found mod_nntp_like where is mention in
>> ap_pass_brigade(c->output_filters,bb);
>> and in smtp_core is usage the same.
>>
>
> Those are protocol modules.  So anything-HTTP is not relevant to them.
>
>  Unfortunatelly when I am using ap_pass_brigade(r->output_filter,bb);
>> then it is not working. Web page is not show.
>>
>
> Do you need to use anything more complex than the ap_r* family
> (ap_rputs, etc)?  If so (and if what Graham already told you isn't
> enough) you might want my book - details at http://www.apachetutor.org/
>
>

Mime
View raw message