@@ -3,8 +3,6 @@ use warnings;
3
3
use Test;
4
4
use Win32;
5
5
use Digest::SHA;
6
- use POSIX qw( locale_h) ;
7
- setlocale(LC_ALL, " C" ); # to make error messages predictable
8
6
9
7
my $tmpfile = " http-download-test-$$ .tgz" ;
10
8
END { 1 while unlink $tmpfile ; }
@@ -14,6 +12,9 @@ unless (defined &Win32::HttpGetFile) {
14
12
exit ;
15
13
}
16
14
15
+ # We can only verify specific error messages with a known locale.
16
+ my $english_locale = (Win32::FormatMessage(1) eq " Incorrect function.\r\n " );
17
+
17
18
# We may not always have an internet connection, so don't
18
19
# attempt remote connections unless the user has done
19
20
# set PERL_WIN32_INTERNET_OK=1
@@ -41,7 +42,12 @@ ok($LastError, '12005', "correct error code for invalid URL");
41
42
42
43
my ($ok , $message ) = HttpGetFileList(' nonesuch://example.com' , ' NUL:' );
43
44
ok($ok , " " , " 'nonesuch://' is not a real protocol" );
44
- ok($message , " The URL does not use a recognized protocol\r\n " , " correct bad protocol message" );
45
+ if ($english_locale ) {
46
+ ok($message , " The URL does not use a recognized protocol\r\n " , " correct bad protocol message" );
47
+ }
48
+ else {
49
+ skip(" Cannot verify error on non-English locale setting" );
50
+ }
45
51
ok($LastError , ' 12006' , " correct error code for unrecognized protocol with list context return" );
46
52
47
53
if ($ENV {PERL_WIN32_INTERNET_OK }) {
@@ -58,8 +64,12 @@ if ($ENV{PERL_WIN32_INTERNET_OK}) {
58
64
59
65
my ($ok , $message ) = HttpGetFileList(' https://cpan.metacpan.org/authors/id/Z/ZZ/ZILCH/nonesuch.tar.gz' , ' NUL:' );
60
66
ok($ok , ' ' , ' Download of nonexistent file from real site should fail with 404' );
61
- ok($message , ' Not Found' , ' Should get text of 404 message' );
62
-
67
+ if ($english_locale ) {
68
+ ok($message , ' Not Found' , ' Should get text of 404 message' );
69
+ }
70
+ else {
71
+ skip(" Cannot verify error on non-English locale setting" );
72
+ }
63
73
# Since all GitHub downloads use redirects, we can test that they work.
64
74
ok(Win32::HttpGetFile(' https://github.com/perl-libwin32/win32/archive/refs/tags/v0.57.zip' , $tmpfile ),
65
75
' 1' ,
0 commit comments