You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Akhil Jaggarwal <ak...@gmail.com> on 2020/04/06 23:53:46 UTC

[users@httpd] adding a header to request_rec in an input filter of type AP_FTYPE_RESOURCE

hi,

I've an input filter of type AP_FTYPE_RESOURCE.

I'm trying to add a custom header to request_rec->headers_in. Here's
how i do it when I see an EOS:

apr_table_set(f->r->headers_in, "MY_CUSTOM_HDR", "CUSTOM_VAL");

But for some reason the header doesn't persist when i read the request
object back on the receiving side.

Is this the correct way to add a custom header to request_rec in a filter?
Does an input filter of type AP_FTYPE_RESOURCE allow to modify
request_rec->headers_in?

Thanks in advance for your help.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] adding a header to request_rec in an input filter of type AP_FTYPE_RESOURCE

Posted by Akhil Jaggarwal <ak...@gmail.com>.
The filter saves the file in the requesty body given in a
multipart/form-data format, hence an input filter. I found using a
filter more suitable for this purpose.

> What's reading it back specifically?
Once the file is saved, the control is passed on to a handler attached
to the called URI (something like /handle/upload/file) which is
another process. That process operates independently on the uploaded
file but relies on the custom header to obtain the name of the
uploaded file.

> Yes, but it is after most other processing that would be reading r->headers_in
Does that imply I need to hook the filter to run first or reallly
first? Right now it's hooked a APR_HOOK_MIDDLE.


On Mon, Apr 6, 2020 at 8:00 PM Eric Covener <co...@gmail.com> wrote:
>
> On Mon, Apr 6, 2020 at 7:54 PM Akhil Jaggarwal
> <ak...@gmail.com> wrote:
> >
> > hi,
> >
> > I've an input filter of type AP_FTYPE_RESOURCE.
> >
> > I'm trying to add a custom header to request_rec->headers_in. Here's
> > how i do it when I see an EOS:
> >
> > apr_table_set(f->r->headers_in, "MY_CUSTOM_HDR", "CUSTOM_VAL");
> >
> > But for some reason the header doesn't persist when i read the request
> > object back on the receiving side.
>
> What's reading it back specifically?
>
> The input filter won't be called until the "handler" is reading the
> body to consume it which will happen after almost everything else in
> the server.
>
> > Is this the correct way to add a custom header to request_rec in a filter?
>
> it is unusually late during request processing.  You should use
> something like post_read_request or fixups both of which are much
> simpler as they are not even filters.
>
> > Does an input filter of type AP_FTYPE_RESOURCE allow to modify
> > request_rec->headers_in?
>
> Yes, but it is after most other processing that would be reading r->headers_in.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] adding a header to request_rec in an input filter of type AP_FTYPE_RESOURCE

Posted by Eric Covener <co...@gmail.com>.
On Mon, Apr 6, 2020 at 7:54 PM Akhil Jaggarwal
<ak...@gmail.com> wrote:
>
> hi,
>
> I've an input filter of type AP_FTYPE_RESOURCE.
>
> I'm trying to add a custom header to request_rec->headers_in. Here's
> how i do it when I see an EOS:
>
> apr_table_set(f->r->headers_in, "MY_CUSTOM_HDR", "CUSTOM_VAL");
>
> But for some reason the header doesn't persist when i read the request
> object back on the receiving side.

What's reading it back specifically?

The input filter won't be called until the "handler" is reading the
body to consume it which will happen after almost everything else in
the server.

> Is this the correct way to add a custom header to request_rec in a filter?

it is unusually late during request processing.  You should use
something like post_read_request or fixups both of which are much
simpler as they are not even filters.

> Does an input filter of type AP_FTYPE_RESOURCE allow to modify
> request_rec->headers_in?

Yes, but it is after most other processing that would be reading r->headers_in.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org