You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Matt Hauck <ma...@gmail.com> on 2014/08/01 06:21:44 UTC

[users@httpd] How to use ap_parse_form_data and keep request body?

I am developing a module for apache that performs some authentication
before passing requests off to the backend. Some of this authentication at
times requires parsing form data. The problem is that ap_parse_form_data
appears to exhaust the request body, so that by the time it passes my
module and gets to the ProxyPass directive which funnels it off to the
backend, the request body is gone and the backend thinks there is no form
data supplied.

Is there any way to use ap_parse_form_data in such a way that it keeps the
request body intact?

Thanks.

(PS. I asked this question on stackoverflow
<http://stackoverflow.com/questions/25071396/how-to-use-ap-parse-form-data-and-keep-request-body>
first,
then decide to ask it here as well since apache-module questions did not
seem to be very well represented on stackoverflow...)

-- 
Matt

[users@httpd] Re: How to use ap_parse_form_data and keep request body?

Posted by Matt Hauck <ma...@gmail.com>.
So, I've been looking into how to do this possibly by dynamically enabling
the KeptBodySize. I can't seem to use this directive directly in my config
because the URLs I am working with get ProxyPass'ed to a different backend,
and do not correspond to any `Directory` element, as KeptBodySize only
appears to be applicable to Directory contexts...

The following seems like it should work:

static my_request_insert_filter(request_rec *req) {
   if (is_login_request(req)) {
       request_dir_conf *conf = ap_get_module_config(req->per_dir_config,
           &request_module);

       conf->keep_body = 8192;
       conf->keep_body_set = TRUE;

       apr_OFN_ap_request_insert_filter_t(req);
   }
}


However, the linker fails on "unresolved external symbol request_module".
Is this the right way to do about doing things? Is there a way to
lookup request_module
dynamically rather than a reference to it at compile time?

Help appreciated. Thanks.



On Thu, Jul 31, 2014 at 9:21 PM, Matt Hauck <ma...@gmail.com> wrote:

> I am developing a module for apache that performs some authentication
> before passing requests off to the backend. Some of this authentication at
> times requires parsing form data. The problem is that ap_parse_form_data
> appears to exhaust the request body, so that by the time it passes my
> module and gets to the ProxyPass directive which funnels it off to the
> backend, the request body is gone and the backend thinks there is no form
> data supplied.
>
> Is there any way to use ap_parse_form_data in such a way that it keeps the
> request body intact?
>
> Thanks.
>
> (PS. I asked this question on stackoverflow
> <http://stackoverflow.com/questions/25071396/how-to-use-ap-parse-form-data-and-keep-request-body> first,
> then decide to ask it here as well since apache-module questions did not
> seem to be very well represented on stackoverflow...)
>
> --
> Matt
>



-- 
Matt