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
3 changes: 3 additions & 0 deletions lib/download.gi
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ InstallMethod( Download,
function( url, opt )
local timeout, errors, r, res;

# Do not modify the caller's record when filling in the defaults below.
opt:= ShallowCopy( opt );

# Set the default for 'verifyCert' if necessary.
if not IsBound( opt.verifyCert ) and
UserPreference( "utils", "DownloadVerifyCertificate" ) = false then
Expand Down
15 changes: 14 additions & 1 deletion tst/download.tst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#@local meths, i, urls, pair, url, expected, res1, good1, n, file, res2, good2, contents, r, res3, good3, bad, server, baseurl, iometh
#@local meths, i, urls, pair, url, expected, res1, good1, n, file, res2, good2, contents, r, res3, good3, bad, server, baseurl, iometh, opt, oldpref
############################################################################
##
#W download.tst Utils Package Thomas Breuer
Expand Down Expand Up @@ -139,6 +139,19 @@ gap> res1:= Download( url, rec( maxTime:= 5 ) );;
gap> res1.success = true;
true

## 'Download' must not modify the given options record.
## The defaults are filled in only when the preferences differ from their
## default values, hence the 'SetUserPreference' call.
gap> oldpref:= UserPreference( "utils", "DownloadMaxTime" );;
gap> SetUserPreference( "utils", "DownloadMaxTime", 30 );
gap> opt:= rec();;
gap> res1:= Download( Concatenation( baseurl, "/success" ), opt );;
gap> res1.success;
true
gap> RecNames( opt );
[ ]
gap> SetUserPreference( "utils", "DownloadMaxTime", oldpref );

## test errors and redirects
gap> res1:= Download( Concatenation( baseurl, "/missing" ) );;
gap> res1.success = false;
Expand Down