Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/HTTP/UserAgent.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ role Connection {
}
}

has Int $.timeout is rw = 180;
has Int $.timeout is rw;
has $.useragent;
has HTTP::Cookies $.cookies is rw = HTTP::Cookies.new(
file => tempfile[0],
Expand Down Expand Up @@ -71,7 +71,7 @@ my sub _index_buf(Blob $input, Blob $sub) {
-1
}

submethod BUILD(:$!useragent, Bool :$!throw-exceptions, :$!max-redirects = 5, :$!debug, :$!redirects-in-a-row) {
submethod BUILD(:$!useragent, Bool :$!throw-exceptions, :$!max-redirects = 5, :$!debug, :$!redirects-in-a-row, :$!timeout = 180) {
$!useragent = get-ua($!useragent) if $!useragent.defined;
if $!debug.defined {
if $!debug ~~ Bool and $!debug == True {
Expand Down
7 changes: 6 additions & 1 deletion t/080-ua.rakutest
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use Test;

use URI;

plan 11;
plan 13;

# new
my $ua = HTTP::UserAgent.new;
Expand Down Expand Up @@ -108,4 +108,9 @@ else {
skip "NETWORK_TESTING not set", 8;
}

$ua = HTTP::UserAgent.new;
is $ua.timeout, 180, 'default timeout provided';
$ua = HTTP::UserAgent.new: timeout => 120;
is $ua.timeout, 120, 'constructor accepts timeout';

# vim: expandtab shiftwidth=4