httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pelikan Stephan" <s.peli...@apa.at>
Subject WG: POST-data in multiple states of a request
Date Thu, 23 Jan 2003 09:00:59 GMT
> I want to know how to read POST data from an apache module without loosing the data for
subsequent modules on Apache 2.0.x.
> Thanks,
> Divya.

I provided a solution for apache 1.3.x perhaps it works for 2.0.x too!

stephan


-----Urspr√ľngliche Nachricht-----
Von: Pelikan Stephan 
Gesendet: Mittwoch, 18. Dezember 2002 08:50
An: 'apreq-dev@httpd.apache.org'
Betreff: WG: POST-data in multiple states of a request


Hi again,

I'm sorry but I sent the HP-UX source which doesn't work for
linux. The right version is:

ApacheRequest *ApacheRequest_new(request_rec *r)
{
    ApacheRequest *req=0;
    char tmp[50];

    const char *ereq = ap_table_get(r->notes, "ApacheRequestAddress");
    if ((ereq != NULL) && ((sscanf(ereq, "%p", &req)) != EOF)) return req;

    req = (ApacheRequest *) ap_pcalloc(r->pool, sizeof(ApacheRequest));
    req->status = OK;
    req->parms = ap_make_table(r->pool, DEFAULT_TABLE_NELTS);
    req->upload = NULL;
    req->post_max = -1;
    req->disable_uploads = 0;
    req->upload_hook = NULL;
    req->hook_data = NULL;
    req->temp_dir = NULL;
    req->parsed = 0;
    req->r = r;

    sprintf(tmp, "%p", (void *) req);
    ap_table_set(r->notes, "ApacheRequestAddress", tmp);

    return req;
}

"sscanf" on HP-UX also handles NULL-pointers but on linux it doesn't.

Sorry,

Stephan


-----Urspr√ľngliche Nachricht-----
Von: Pelikan Stephan 
Gesendet: Mittwoch, 18. Dezember 2002 08:38
An: apreq-dev@httpd.apache.org
Betreff: POST-data in multiple states of a request


Hi,

I wrote several Apache-modules which use formular-field's data
and use libapreq and Apache::Request to handle those data. This
modules are concatinated in the same request during different
request-phases.

This works fine as long as I use the GET-method because the
formular's data are store permanently in the request-record and
can be extracted by every new generated object. Sometimes it is
necessary to do a POST-request and you know what happens: The
first object retrieves the data and all other modules get nothing.

So I did a patch and I hope you may include it into the source:

c/apache_request.c:

ApacheRequest *ApacheRequest_new(request_rec *r)
{
    ApacheRequest *req=0;
    char tmp[50];

    const char *ereq = ap_table_get(r->notes, "ApacheRequestAddress");
    if ((sscanf(ereq, "%p", &req)) != EOF) return req;

    req = (ApacheRequest *) ap_pcalloc(r->pool, sizeof(ApacheRequest));
    req->status = OK;
    req->parms = ap_make_table(r->pool, DEFAULT_TABLE_NELTS);
    req->upload = NULL;
    req->post_max = -1;
    req->disable_uploads = 0;
    req->upload_hook = NULL;
    req->hook_data = NULL;
    req->temp_dir = NULL;
    req->parsed = 0;
    req->r = r;

    sprintf(tmp, "%p", (void *) req);
    ap_table_set(r->notes, "ApacheRequestAddress", tmp);

    return req;
}

My trick is to return always the same object by storing the
object's address in the request's notes. If it is there it will
be returned otherwise the object will be created.

I hope this is not "too dirty", but it works really fine and it is
well-proven for more than 1 year. What do you think about it?

regards,

Stephan

Mime
View raw message