Skip to content
4 changes: 2 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ my %param = (
$param{NO_META} = 1 if eval "$ExtUtils::MakeMaker::VERSION" >= 6.10_03;

if ($^O eq 'cygwin') {
$param{LIBS} = ['-L/lib/w32api -lole32 -lversion -luserenv -lnetapi32']
$param{LIBS} = ['-L/lib/w32api -lole32 -lversion -luserenv -lnetapi32 -lwinhttp']
}
else {
$param{LIBS} = ['-luserenv']
$param{LIBS} = ['-luserenv -lwinhttp']
}

my $test_requires = $ExtUtils::MakeMaker::VERSION >= 6.64
Expand Down
43 changes: 42 additions & 1 deletion Win32.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1305,11 +1305,52 @@ of hex digits with surrounding braces. For example:

{09531CF1-D0C7-4860-840C-1C8C8735E2AD}

=item Win32::HttpGetFile(URL, FILENAME [, IGNORE_CERT_ERRORS])

Uses the WinHttp library to download the file specified by the URL
parameter to the local file specified by FILENAME. The optional third
parameter, if true, indicates that certficate errors are to be ignored
for https connections; please use with caution in a safe environment,
such as when testing locally using a self-signed certificate.

Only http and https protocols are supported. Authentication is not
supported. The function is not available when building with gcc prior to
4.8.0 because the WinHttp library is not available.

In scalar context returns a boolean success or failure, and in list
context also returns, in addition to the boolean status, a second
value containing message text related to the status.

If the call fails, C<Win32::GetLastError()> will return a numeric
error code, which may be a system error, a WinHttp error, or a
user-defined error composed of 1e9 plus the HTTP status code.

Scalar context example:

print Win32::GetLastError()
unless Win32::HttpGetFile('http://example.com/somefile.tar.gz',
'.\file.tgz');

List context example:

my ($ok, $msg) = Win32::HttpGetFile('http://example.com/somefile.tar.gz',
'.\file.tgz');
if ($ok) {
print "Success!: $msg\n";
}
else {
print "Failure!: $msg\n";
my $err = Win32::GetLastError();
if ($err > 1e9) {
printf "HTTP status: %d\n", ($err - 1e9);
}
}

=item Win32::InitiateSystemShutdown

(MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)

Shutsdown the specified MACHINE, notifying users with the
Shuts down the specified MACHINE, notifying users with the
supplied MESSAGE, within the specified TIMEOUT interval. Forces
closing of all documents without prompting the user if FORCECLOSE is
true, and reboots the machine if REBOOT is true. This function works
Expand Down
Loading