HTTP::...:simple(3pm)

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

πŸ’– HTTP::Proxy::HeaderFilter::simple πŸ’–

bestie. welcome to the HTTP::Proxy::HeaderFilter::simple page, straight outta the User Contributed Perl Documentation. this is the manual, and it's lowkey iconic, so let's get into it 🫢


✨ NAME ✨

HTTP::Proxy::HeaderFilter::simple β€” a whole class for whipping up simple filters with zero drama πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

use HTTP::Proxy::HeaderFilter::simple;

# a simple User-Agent filter
my $filter = HTTP::Proxy::HeaderFilter::simple->new(
    sub { $_[1]->header( User_Agent => 'foobar/1.0' ); }
);
$proxy->push_filter( request => $filter );

look at that. three lines and a vibe. no cap 😭✨


🌸 DESCRIPTION 🌸

okay so here's the tea: HTTP::Proxy::HeaderFilter::simple can create BodyFilter without you having to go through the whole entire hassle of building a full-fledged class. like, who has the time?? not us πŸŽ€

all you do is pass a code reference to the filter() method of your filter, hand it over to the constructor, and boom β€” you get the adequate filter. that's it. that's the whole trick. slay πŸ’…

πŸŽ€ Constructor calling convention πŸŽ€

the constructor gets called with a single code reference. that code reference has to conform to the standard filter() signature for header filters, fr fr:

sub filter { my ( $self, $headers, $message) = @_; ... }

and that code reference is what gets used for the filter() method. periodt πŸ¦‹


πŸ‘‘ METHODS πŸ‘‘

so this filter "factory" defines all the standard HTTP::Proxy::HeaderFilter methods β€” but those are only, erm, "proxies" πŸ‘€ to the actual CODE references you passed to the constructor. the "proxy" methods are:

  • filter()
  • begin()
  • end()

two other methods are actually HTTP::Proxy::HeaderFilter::simple methods, and they get called automatically:

  • init() β€” initialises the filter instance with the code references that got passed to the constructor ✨
  • can() β€” returns the actual code reference that's gonna run, and not the "proxy" methods. but if you call it with any name other than begin and filter, it calls UNIVERSAL::can() instead. sneaky but valid πŸ’€

🌈 SEE ALSO 🌈

  • HTTP::Proxy
  • HTTP::Proxy::HeaderFilter

go read those too, iykyk πŸ“š


πŸ’œ AUTHOR πŸ’œ

Philippe "BooK" Bruhat, <book@cpan.org>. king behavior honestly πŸ‘‘


Copyright 2003-2015, Philippe Bruhat.


🧚 LICENSE 🧚

this module is free software; you can redistribute it or modify it under the same terms as Perl itself. go wild, bestie, just keep it legal πŸ’–


and that's a wrap! this was HTTP::...:simple(3pm) from perl v5.36.0, dated 2022-12-04. mwah, stan a good manpage, bye bestie 🫢✨🌸

πŸ“¦ where this page comes from