1 /*
2  * Copyright (c) 2013 Tim Ruehsen
3  * Copyright (c) 2015-2021 Free Software Foundation, Inc.
4  *
5  * This file is part of Wget
6  *
7  * Wget is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * Wget is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Wget  If not, see <https://www.gnu.org/licenses/>.
19  *
20  *
21  * Testing Wget
22  *
23  * Changelog
24  * 17.07.2013  Tim Ruehsen  created
25  *
26  */
27 
28 #include <config.h>
29 
30 #include <stdlib.h> // exit()
31 #include "libtest.h"
32 
33 // Kon'nichiwa <dot> Japan
34 #define euc_jp_hostname "\272\243\306\374\244\317.\306\374\313\334"
35 #ifndef _WIN32
36 #  define utf8_hostname "\344\273\212\346\227\245\343\201\257.\346\227\245\346\234\254"
37 #endif
38 #define punycoded_hostname "xn--v9ju72g90p.xn--wgv71a"
39 
main(void)40 int main(void)
41 {
42 	wget_test_url_t urls[]={
43 		{	.name = "http://" punycoded_hostname "/index.html",
44 			.code = "200 Dontcare",
45 			.body = "What ever",
46 			.headers = {
47 				"Content-Type: text/plain",
48 			}
49 		},
50 	};
51 
52 	char options[256];
53 
54 	// functions won't come back if an error occurs
55 	wget_test_start_server(
56 		WGET_TEST_RESPONSE_URLS, &urls, countof(urls),
57 		WGET_TEST_FEATURE_MHD,
58 		WGET_TEST_FEATURE_IDN,
59 		0);
60 
61 	// test-idn-cmd
62 	wget_snprintf(options, sizeof(options),
63 		"--iri -rH -e http_proxy=localhost:{{port}} -e https_proxy=localhost:{{sslport}} --local-encoding=EUC-JP " euc_jp_hostname);
64 
65 	wget_test(
66 //		WGET_TEST_KEEP_TMPFILES, 1,
67 		WGET_TEST_OPTIONS, options,
68 		WGET_TEST_REQUEST_URL, NULL,
69 		WGET_TEST_EXPECTED_ERROR_CODE, 0,
70 		WGET_TEST_EXPECTED_FILES, &(wget_test_file_t []) {
71 			{ punycoded_hostname "/index.html", urls[0].body },
72 			{	NULL } },
73 		0);
74 
75 // UTF-8 command line characters are mangled on MinGW on C locale
76 #ifndef _WIN32
77 	// test-idn-cmd
78 	wget_snprintf(options, sizeof(options),
79 		"--iri -rH -e http_proxy=localhost:{{port}} -e https_proxy=localhost:{{sslport}} --local-encoding=UTF-8 " utf8_hostname);
80 
81 	wget_test(
82 //		WGET_TEST_KEEP_TMPFILES, 1,
83 		WGET_TEST_OPTIONS, options,
84 		WGET_TEST_REQUEST_URL, NULL,
85 		WGET_TEST_EXPECTED_ERROR_CODE, 0,
86 		WGET_TEST_EXPECTED_FILES, &(wget_test_file_t []) {
87 			{ punycoded_hostname "/index.html", urls[0].body },
88 			{	NULL } },
89 		0);
90 #endif
91 
92 	exit(EXIT_SUCCESS);
93 }
94