1HTTP::Proxy::BodyFilterU:s:esrimCpolnet(r3i)buted Perl DHoTcTuPm:e:nPtraotxiyo:n:BodyFilter::simple(3)
2
3
4

NAME

6       HTTP::Proxy::BodyFilter::simple - A class for creating simple filters
7

SYNOPSIS

9           use HTTP::Proxy::BodyFilter::simple;
10
11           # a simple s/// filter
12           my $filter = HTTP::Proxy::BodyFilter::simple->new(
13               sub { ${ $_[1] } =~ s/foo/bar/g; }
14           );
15           $proxy->push_filter( response => $filter );
16

DESCRIPTION

18       HTTP::Proxy::BodyFilter::simple can create BodyFilter without going
19       through the hassle of creating a full-fledged class. Simply pass a code
20       reference to the filter() method of your filter to the constructor, and
21       you'll get the adequate filter.
22
23   Constructor calling convention
24       The constructor can be called in several ways, which are shown in the
25       synopsis:
26
27       single code reference
28           The code reference must conform to the standard filter() signature:
29
30               sub filter {
31                   my ( $self, $dataref, $message, $protocol, $buffer ) = @_;
32                   ...
33               }
34
35           It is assumed to be the code for the filter() method.  See
36           HTTP::Proxy::BodyFilter for more details about the filter() method.
37
38       name/coderef pairs
39           The name is the name of the method ("filter", "begin", "end") and
40           the coderef is the method itself.
41
42           See HTTP::Proxy::BodyFilter for the methods signatures.
43

METHODS

45       This filter "factory" defines the standard HTTP::Proxy::BodyFilter
46       methods, but those are only, erm, "proxies" to the actual CODE
47       references passed to the constructor. These "proxy" methods are:
48
49       filter()
50       begin()
51       end()
52
53       Two other methods are actually HTTP::Proxy::BodyFilter::simple methods,
54       and are called automatically:
55
56       init()
57           Initalise the filter instance with the code references passed to
58           the constructor.
59
60       can()
61           Return the actual code reference that will be run, and not the
62           "proxy" methods. If called with any other name than "begin", "end"
63           and "filter", calls UNIVERSAL::can() instead.
64
65       There is also a method that returns a boolean value:
66
67       will_modify()
68           The will_modify() method returns a scalar value (boolean)
69           indicating if the filter may modify the body data. The default
70           method returns a true value, so you only need to set this value
71           when you are absolutely certain that the filter will not modify
72           data (or at least not modify its final length).
73
74           Here's a simple example:
75
76               $filter = HTTP::Proxy::BodyFilter::simple->new(
77                   filter => sub { ${ $_[1] } =~ s/foo/bar/g; },
78                   will_modify => 0,    # "foo" is the same length as "bar"
79               );
80

SEE ALSO

82       HTTP::Proxy, HTTP::Proxy::BodyFilter.
83

AUTHOR

85       Philippe "BooK" Bruhat, <book@cpan.org>.
86
88       Copyright 2003-2015, Philippe Bruhat.
89

LICENSE

91       This module is free software; you can redistribute it or modify it
92       under the same terms as Perl itself.
93
94
95
96perl v5.36.0                      2023-01-20HTTP::Proxy::BodyFilter::simple(3)
Impressum