File: https.t

package info (click to toggle)
libanyevent-connector-perl 0.04-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 144 kB
  • sloc: perl: 182; makefile: 2
file content (32 lines) | stat: -rw-r--r-- 742 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use Test::More;
use AnyEvent;
use AnyEvent::Connector;
use AnyEvent::HTTP qw(http_get);

my $ENV_NAME = "PERL_ANYEVENT_CONNECTOR_TEST_PROXY";
my $proxy_url = $ENV{$ENV_NAME};
if(!defined($proxy_url)) {
    plan skip_all => "Set $ENV_NAME environment variable to proxy URL.";
    exit 0;
}

my $conn = AnyEvent::Connector->new(
    proxy => $proxy_url
);

AnyEvent::HTTP::set_proxy undef;

my $cv = AnyEvent->condvar;
http_get "https://www.google.com/", tcp_connect => sub { $conn->tcp_connect(@_) }, sub {
    my ($data, $headers) = @_;
    $cv->send($data, $headers);
};
my ($data, $headers) = $cv->recv;
like $headers->{Status}, qr/^2\d\d$/, "successful status";
isnt $data, "", "non-empty data";

done_testing;