Skip to content

Commit 2970ec9

Browse files
committed
gcc before 4.8.x does not have winhttp library
It has a partial winhttp.h header, but not the associated library, so we won't try to build anything based on winhttp there.
1 parent 1b7d402 commit 2970ec9

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

Win32.pm

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,6 +1305,14 @@ of hex digits with surrounding braces. For example:
13051305
13061306
{09531CF1-D0C7-4860-840C-1C8C8735E2AD}
13071307
1308+
=item Win32::HttpGetFile(URL, FILENAME)
1309+
1310+
Uses the WinHttp library to download the file specified by the URL
1311+
parameter to the local file specified by FILENAME. Only http and https
1312+
protocols are supported. Authentication is not supported. The function
1313+
is not available when building with gcc prior to 4.8.0 because the
1314+
winhttp library is not available.
1315+
13081316
=item Win32::InitiateSystemShutdown
13091317
13101318
(MACHINE, MESSAGE, TIMEOUT, FORCECLOSE, REBOOT)
@@ -1472,12 +1480,6 @@ instead.
14721480
Loads the DLL LIBRARYNAME and calls the function
14731481
DllUnregisterServer.
14741482
1475-
=item Win32::HttpGetFile(URL, FILENAME)
1476-
1477-
Uses the WinHttp library to download the file specified by the URL
1478-
parameter to the local file specified by FILENAME. Only http and https
1479-
protocols are supported. Authentication is not supported.
1480-
14811483
=back
14821484
14831485
=head1 CAVEATS

Win32.xs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
#include <wchar.h>
88
#include <userenv.h>
99
#include <lm.h>
10-
#include <winhttp.h>
10+
#if !defined(__GNUC__) || (((100000 * __GNUC__) + (1000 * __GNUC_MINOR__)) >= 408000)
11+
# include <winhttp.h>
12+
#endif
1113

1214
#define PERL_NO_GET_CONTEXT
1315
#include "EXTERN.h"
@@ -1683,6 +1685,7 @@ XS(w32_IsDeveloperModeEnabled)
16831685
XSRETURN_NO;
16841686
}
16851687

1688+
#ifdef WINHTTPAPI
16861689

16871690
XS(w32_HttpGetFile)
16881691
{
@@ -1902,6 +1905,8 @@ XS(w32_HttpGetFile)
19021905
XSRETURN_YES;
19031906
}
19041907

1908+
#endif
1909+
19051910
MODULE = Win32 PACKAGE = Win32
19061911

19071912
PROTOTYPES: DISABLE
@@ -1976,6 +1981,8 @@ BOOT:
19761981
#ifdef __CYGWIN__
19771982
newXS("Win32::SetChildShowWindow", w32_SetChildShowWindow, file);
19781983
#endif
1984+
#ifdef WINHTTPAPI
19791985
newXS("Win32::HttpGetFile", w32_HttpGetFile, file);
1986+
#endif
19801987
XSRETURN_YES;
19811988
}

t/HttpGetFile.t

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ use Digest::SHA;
77
my $tmpfile = "http-download-test-$$.tgz";
88
END { 1 while unlink $tmpfile; }
99

10+
unless (defined &Win32::HttpGetFile) {
11+
print "1..0 # Skip: gcc before 4.8 does not have winhttp library\n";
12+
exit;
13+
}
14+
1015
# We may not always have an internet connection, so don't
1116
# attempt remote connections unless the user has done
1217
# set PERL_WIN32_INTERNET_OK=1

0 commit comments

Comments
 (0)