Welcome! Log In Create A New Profile

Advanced

Re: Getting List of Output Chains Before the Output Filter

Maxim Dounin
August 19, 2022 01:26PM
Hello!

On Wed, Aug 17, 2022 at 09:58:58PM -0400, panamagod25 wrote:

> Good evening,
>
> I'm following the instructions on the developer guide:
>
> http://nginx.org/en/docs/dev/development_guide.html#http_response_body_filters
> and also this github project:
>
> https://github.com/ngchianglin/NginxHtmlHeadFilter/blob/master/ngx_http_html_head_filter_module.c
>
>
> What I'm trying to do is to collect all of the tags on an HTML page, then
> perform an operation on a certain tag group based on tag count? For example:
> I want to add a class to all <div> tags if there are more <div> tags than
> <a> tags.
>
> So, (kind of) like the html_head_filter module from above, I want the parser
> to run on all of the HTML, then do some logic, THEN when it hits the output
> filter, create a c engine which will modify the requisite tag.
>
> Any help you can provide would be very appreciated.

Normally, the full response body is not available in nginx, since
response bodies can be arbitrary big. Instead, nginx processes
the response body as a stream, handling individual buffers with
data.

If in your particular use case response bodies are guaranteed to
be of limited size, and you have to do some processing which needs
the whole response body, you'll have to buffer it in your response
body filter. Examples of such buffering can be found in the image
filter (src/http/modules/ngx_http_image_filter_module.c) and the
xslt filter (src/http/modules/ngx_http_xslt_filter_module.c).

Hope this helps.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

Getting List of Output Chains Before the Output Filter

panamagod25 August 17, 2022 09:58PM

Re: Getting List of Output Chains Before the Output Filter

Maxim Dounin August 19, 2022 01:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 97
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready