### ----------------------------------------------------
### -- Net::HTTP
### -- Licenses: Artistic-2.0
### -- Authors: ugexe
### -- File: xt/100-dialer.rakutest
### ----------------------------------------------------
use Test:ver<6.c+>;
plan 2;

use Net::HTTP::Dialer;
use Net::HTTP::URL;
use Net::HTTP::Request;


subtest 'IO::Socket::INET selected and works' => {
    my $url     = Net::HTTP::URL.new("http://httpbin.org/ip");
    my $method  = 'GET';
    my %header  = :Host<httpbin.org>, :User-Agent("raku-net-http");
    my $request = Net::HTTP::Request.new(:$url, :$method, :%header);
    my $socket  = Net::HTTP::Dialer.new.dial($request);

    ok $socket ~~ IO::Socket::INET, 'IO::Socket::INET';
}


if Net::HTTP::Dialer.?can-ssl {
    subtest 'IO::Socket::SSL selected and works' => {
        my $url     = Net::HTTP::URL.new("https://httpbin.org/ip");
        my $method  = 'GET';
        my %header  = :Host<httpbin.org>, :User-Agent("raku-net-http");
        my $request = Net::HTTP::Request.new(:$url, :$method, :%header);
        my $socket  = Net::HTTP::Dialer.new.dial($request);

        ok $socket ~~ ::('IO::Socket::SSL'), 'IO::Socket::SSL';
    }
}
else {
    ok 1, "Skip: Can't do SSL. Is IO::Socket::SSL available?";
}

done-testing;


