HTTP::...omplete(3pm)

πŸ“¦
version 0.304 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu noble

πŸ’– HTTP::...omplete πŸ’–

okay bestie, welcome to the manual page for HTTP::...omplete, straight out of the User Contributed Perl Documentation, section 3pm. it's giving niche but iconic, and we're gonna get through it together. no cap. πŸŽ€


✨ NAME ✨

HTTP::Proxy::BodyFilter::complete β€” a filter that passes on a complete body or nothing πŸ¦‹

like. all of it or none of it. she does not do half measures.


🌸 SYNOPSIS 🌸

use HTTP::Proxy;
use HTTP::Proxy::BodyFilter::simple;
use HTTP::Proxy::BodyFilter::complete;

my $proxy = HTTP::Proxy->new;

# pass the complete response body to our filter (in one pass)
$proxy->push_filter(
    mime => 'text/html',
    response => HTTP::Proxy::BodyFilter::complete->new,
    response => HTTP::Proxy::BodyFilter::simple->new(
        sub {
            my ( $self, $dataref, $message, $protocol, $buffer ) = @_;
            # some complex processing that needs
            # the whole response body
        }
    );
);

$proxy->start;

periodt. that's the whole vibe. πŸ’…


🧚 DESCRIPTION 🧚

so the HTTP::Proxy::BodyFilter::complete filter is basically the group-chat admin who refuses to forward a message until everyone has finished typing. she makes sure that the next filter in the filter chain only ever receives complete message bodies β€” and yes, that's either request or response, whichever one we're talking about. 🫢

the way she works: she stores the chunks of data as they arrive, and only passes the entire message body along after the whole message has been received by the proxy. lowkey patient, highkey essential.

subsequent filters in the chain will receive the whole body as one big piece of data. no more nibbling at crumbs, bestie β€” full meal. πŸ“


πŸ’€ CAVEAT EMPTOR πŸ’€

this consumes memory and time. πŸ’€

use with caution, otherwise your client will timeout, or your proxy will run out of memory. not me warning you and you ignoring me. 😭

also note that all filters after "complete" are still called when the proxy receives data: they just receive empty data. they will receive the complete data when the filter chain is called for the very last time (the $buffer parameter is undef). (see the documentation of HTTP::Proxy::BodyFilter for details about the $buffer parameter.) πŸ‘‘


⭐ METHOD ⭐

this filter defines two methods, called automatically:

  • filter() β€” stores the incoming data in memory until the last moment and passes empty data to the subsequent filters in the chain. they will receive the full body during the last round of filter calls. πŸŽ€
  • will_modify() β€” this method returns a false value, thus indicating to the system that it will not modify data passing through. she's just the messenger, fr fr. πŸ’…

πŸ’œ AUTHOR πŸ’œ

Philippe "BooK" Bruhat, <book@cpan.org>. iconic name, iconic human. ✨


🌈 THANKS 🌈

thanks to Simon Cozens and Merijn H. Brandt, who needed this almost at the same time. ";-)" πŸ¦‹


Copyright 2004-2015, Philippe Bruhat.


πŸ‘‘ LICENSE πŸ‘‘

this module is free software; you can redistribute it or modify it under the same terms as Perl itself. slay. πŸ’–


and that's the whole page, bestie β€” perl v5.36.0, dated 2022-12-04, brought to you by HTTP::...omplete(3pm). go forth and buffer responsibly. πŸ«Άβœ¨πŸ’…

πŸ“¦ where this page comes from