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,
21       and 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()"
37           method.
38
39       name/coderef pairs
40           The name is the name of the method ("filter", "begin", "end") and
41           the coderef is the method itself.
42
43           See HTTP::Proxy::BodyFilter for the methods signatures.
44

METHODS

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

SEE ALSO

83       HTTP::Proxy, HTTP::Proxy::BodyFilter.
84

AUTHOR

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

LICENSE

92       This module is free software; you can redistribute it or modify it
93       under the same terms as Perl itself.
94
95
96
97perl v5.32.0                      2020-07-28HTTP::Proxy::BodyFilter::simple(3)
Impressum