/usr/share/perl5/Plack/LWPish.pm is in libplack-perl 1.0042-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | package Plack::LWPish;
use strict;
use warnings;
use HTTP::Tiny;
use HTTP::Response;
use Hash::MultiValue;
sub new {
my $class = shift;
my $self = bless {}, $class;
$self->{http} = @_ == 1 ? $_[0] : HTTP::Tiny->new(@_);
$self;
}
sub request {
my($self, $req) = @_;
my @headers;
$req->headers->scan(sub { push @headers, @_ });
my $options = {
headers => Hash::MultiValue->new(@headers)->mixed,
};
$options->{content} = $req->content if defined $req->content && length($req->content);
my $response = $self->{http}->request($req->method, $req->url, $options);
my $res = HTTP::Response->new(
$response->{status},
$response->{reason},
[ Hash::MultiValue->from_mixed($response->{headers})->flatten ],
$response->{content},
);
$res->request($req);
return $res;
}
1;
__END__
=head1 NAME
Plack::LWPish - HTTP::Request/Response compatible interface with HTTP::Tiny backend
=head1 SYNOPSIS
use Plack::LWPish;
my $request = HTTP::Request->new(GET => 'http://perl.com/');
my $ua = Plack::LWPish->new;
my $res = $ua->request($request); # returns HTTP::Response
=head1 DESCRIPTION
This module is an adapter object that implements one method,
C<request> that acts like L<LWP::UserAgent>'s request method
i.e. takes HTTP::Request object and returns HTTP::Response object.
This module is used solely inside L<Plack::Test::Suite> and
L<Plack::Test::Server>, and you are recommended to take a look at
L<HTTP::Thin> if you would like to use this outside Plack.
=head1 AUTHOR
Tatsuhiko Miyagawa
=head1 SEE ALSO
L<HTTP::Thin> L<HTTP::Tiny> L<LWP::UserAgent>
=cut
|