1HTTP::Proxy::BodyFilterU:s:ecromCpolnettrei(b3u)ted PerlHTDToPc:u:mPernotxayt:i:oBnodyFilter::complete(3)
2
3
4
6 HTTP::Proxy::BodyFilter::complete - A filter that passes on a complete
7 body or nothing
8
10 use HTTP::Proxy;
11 use HTTP::Proxy::BodyFilter::simple;
12 use HTTP::Proxy::BodyFilter::complete;
13
14 my $proxy = HTTP::Proxy->new;
15
16 # pass the complete response body to our filter (in one pass)
17 $proxy->push_filter(
18 mime => 'text/html',
19 response => HTTP::Proxy::BodyFilter::complete->new,
20 response => HTTP::Proxy::BodyFilter::simple->new(
21 sub {
22 my ( $self, $dataref, $message, $protocol, $buffer ) = @_;
23 # some complex processing that needs
24 # the whole response body
25 }
26 );
27 );
28
29 $proxy->start;
30
32 The HTTP::Proxy::BodyFilter::complete filter will ensure that the next
33 filter in the filter chain will only receive complete message bodies
34 (either request or response).
35
36 It will store the chunks of data as they arrive, only to pass the
37 entire message body after the whole message has been received by the
38 proxy.
39
40 Subsequent filters is the chain will receive the whole body as a big
41 piece of data.
42
44 This consumes memory and time.
45
46 Use with caution, otherwise your client will timeout, or your proxy
47 will run out of memory.
48
49 Also note that all filters after "complete" are still called when the
50 proxy receives data: they just receive empty data. They will receive
51 the complete data when the filter chain is called for the very last
52 time (the $buffer parameter is "undef"). (See the documentation of
53 HTTP::Proxy::BodyFilter for details about the $buffer parameter.)
54
56 This filter defines two methods, called automatically:
57
58 filter()
59 Stores the incoming data in memory until the last moment and passes
60 empty data to the subsequent filters in the chain. They will
61 receive the full body during the last round of filter calls.
62
63 will_modify()
64 This method returns a false value, thus indicating to the system
65 that it will not modify data passing through.
66
68 Philippe "BooK" Bruhat, <book@cpan.org>.
69
71 Thanks to Simon Cozens and Merijn H. Brandt, who needed this almost at
72 the same time. ";-)"
73
75 Copyright 2004-2015, Philippe Bruhat.
76
78 This module is free software; you can redistribute it or modify it
79 under the same terms as Perl itself.
80
81
82
83perl v5.34.0 2021-07-2H2TTP::Proxy::BodyFilter::complete(3)