httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "CpServiceSPb ." <cpservice...@gmail.com>
Subject What is the best way of reading of post request body at hooks module from 2 hooks procedures (+) ?
Date Fri, 15 May 2020 21:39:07 GMT
I write hook module for Apache2 consisted of hooks of 2 procedures:
ap_hook_check_authn/ap_hook_check_user_id and ap_hook_handler.
This module reads content of post method request, mainly body, and extract
necessary information for functioning of the each of mentioned above
procedure.
For 1st one - it is user/password passed from clients at post request body,
for 2nd one - it is some data.
That is reading post request body content from brigades/buckets and saving
it into char buffer is called twice - from ap_hook_check_authn and and
ap_hook_handler.
But after callig reading post request body content reading function for the
first time from ap_hook_check_authn, other calling of the function (from
ap_hook_handler) returns an empty body buffer.
Even other calling of post request body content reading function from
ap_hook_check returns already an emptybody biffer.

I read post body to a buffer at the following way:
1. apr_brigade_create
2. do-while cycle until eos_bucket is got set to 1
3. within the point 2 cycle ap_get_brigade
4. in for (bucket = APR_BRIGADE_FIRST(bb); bucket !=
APR_BRIGADE_SENTINEL(bb); bucket = APR_BUCKET_NEXT(bucket))
if bucket EOS then eos_bucket set to 1
else (transien bucket) apr_bucket_read is called and then all chunks are
reads to buffer
5. body buffer and its len is got finally

But in such pot body reading all buckest are deleted from brigade (not by
me) .

So what is the best way to read post body content to a buffer as many times
as necessary as at ap_hook_check_authn step as at ap_hook_handler step
without loosing the content ?
Or may be it's more efficiency to read post body content once at
ap_hook_check_authn and then pass it to ap_hook_handler ?
But I don' t understand now how.

P. S.:
Way of calling of

r->kept_body = apr_brigade_create(r->pool, r->connection->bucket_alloc);
apr_bucket *bucketnew = apr_bucket_transient_create(bodycontent, bodysize,
r->connection->bucket_alloc);
APR_BRIGADE_INSERT_TAIL(r->kept_body, bucketnew);

after 1st calling of post request body content reading function worked for
some versions ago (may be even for 2.2 only) .
But it doesn' t work now.

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