16 DWORD dwInternetStatus,
17 LPVOID lpvStatusInformation,
18 DWORD dwStatusInformationLength
23 switch (dwInternetStatus)
25 case INTERNET_STATUS_RESOLVING_NAME:
26 strcpy(name,"INTERNET_STATUS_RESOLVING_NAME");
28 case INTERNET_STATUS_NAME_RESOLVED:
29 strcpy(name,"INTERNET_STATUS_NAME_RESOLVED");
31 case INTERNET_STATUS_CONNECTING_TO_SERVER:
32 strcpy(name,"INTERNET_STATUS_CONNECTING_TO_SERVER");
34 case INTERNET_STATUS_CONNECTED_TO_SERVER:
35 strcpy(name,"INTERNET_STATUS_CONNECTED_TO_SERVER");
37 case INTERNET_STATUS_SENDING_REQUEST:
38 strcpy(name,"INTERNET_STATUS_SENDING_REQUEST");
40 case INTERNET_STATUS_REQUEST_SENT:
41 strcpy(name,"INTERNET_STATUS_REQUEST_SENT");
43 case INTERNET_STATUS_RECEIVING_RESPONSE:
44 strcpy(name,"INTERNET_STATUS_RECEIVING_RESPONSE");
46 case INTERNET_STATUS_RESPONSE_RECEIVED:
47 strcpy(name,"INTERNET_STATUS_RESPONSE_RECEIVED");
49 case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
50 strcpy(name,"INTERNET_STATUS_CTL_RESPONSE_RECEIVED");
52 case INTERNET_STATUS_PREFETCH:
53 strcpy(name,"INTERNET_STATUS_PREFETCH");
55 case INTERNET_STATUS_CLOSING_CONNECTION:
56 strcpy(name,"INTERNET_STATUS_CLOSING_CONNECTION");
58 case INTERNET_STATUS_CONNECTION_CLOSED:
59 strcpy(name,"INTERNET_STATUS_CONNECTION_CLOSED");
61 case INTERNET_STATUS_HANDLE_CREATED:
62 strcpy(name,"INTERNET_STATUS_HANDLE_CREATED");
64 case INTERNET_STATUS_HANDLE_CLOSING:
65 strcpy(name,"INTERNET_STATUS_HANDLE_CLOSING");
67 case INTERNET_STATUS_REQUEST_COMPLETE:
68 strcpy(name,"INTERNET_STATUS_REQUEST_COMPLETE");
71 case INTERNET_STATUS_REDIRECT:
72 strcpy(name,"INTERNET_STATUS_REDIRECT");
74 case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
75 strcpy(name,"INTERNET_STATUS_INTERMEDIATE_RESPONSE");
79 trace("Callback %p 0x%lx %s(%li) %p %ld\n",hInternet,dwContext,name,dwInternetStatus,lpvStatusInformation,dwStatusInformationLength);
82 void winapi_test(int flags)
88 const char *types[2] = { "*", NULL };
89 HINTERNET hi, hic = 0, hor = 0;
91 trace("Starting with flags 0x%x\n",flags);
93 trace("InternetOpenA <--\n");
94 hi = InternetOpenA("",0x0,0x0,0x0,flags);
95 ok((hi != 0x0),"InternetOpen Failed");
96 trace("InternetOpenA -->\n");
98 if (hi == 0x0) goto abort;
100 InternetSetStatusCallback(hi,&callback);
102 trace("InternetConnectA <--\n");
103 hic=InternetConnectA(hi,"www.winehq.com",0x0,0x0,0x0,0x3,0x0,0xdeadbeef);
104 ok((hic != 0x0),"InternetConnect Failed");
105 trace("InternetConnectA -->\n");
107 if (hic == 0x0) goto abort;
109 trace("HttpOpenRequestA <--\n");
110 hor = HttpOpenRequestA(hic, "GET",
112 0x0,0x0,types,0x00400800,0xdeadbead);
113 if (hor == 0x0 && GetLastError() == 12007 /* ERROR_INTERNET_NAME_NOT_RESOLVED */) {
115 * If the internet name can't be resolved we are probably behind
116 * a firewall or in some other way not directly connected to the
117 * Internet. Not enough reason to fail the test. Just ignore and
121 ok((hor != 0x0),"HttpOpenRequest Failed");
123 trace("HttpOpenRequestA -->\n");
125 if (hor == 0x0) goto abort;
127 trace("HttpSendRequestA -->\n");
129 rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0);
131 ok(((rc == 0)&&(GetLastError()==997)),
132 "Asyncronous HttpSendRequest NOT returning 0 with error 997");
134 ok((rc != 0) || GetLastError() == 12007, /* 12007 == XP */
135 "Syncronous HttpSendRequest returning 0, error %ld", GetLastError());
136 trace("HttpSendRequestA <--\n");
138 while ((flags)&&(!goon))
142 rc = InternetQueryOptionA(hor,0x17,&out,&length);
143 trace("Option 0x17 -> %li %li\n",rc,out);
146 rc = InternetQueryOptionA(hor,0x22,buffer,&length);
147 trace("Option 0x22 -> %li %s\n",rc,buffer);
150 rc = HttpQueryInfoA(hor,0x16,buffer,&length,0x0);
152 trace("Option 0x16 -> %li %s\n",rc,buffer);
155 rc = InternetQueryOptionA(hor,0x22,buffer,&length);
157 trace("Option 0x22 -> %li %s\n",rc,buffer);
160 rc = HttpQueryInfoA(hor,0x5,&buffer,&length,0x0);
161 trace("Option 0x5 -> %li %s (%li)\n",rc,buffer,GetLastError());
164 rc = HttpQueryInfoA(hor,0x1,buffer,&length,0x0);
166 trace("Option 0x1 -> %li %s\n",rc,buffer);
169 trace("Entery Query loop\n");
174 rc = InternetQueryDataAvailable(hor,&length,0x0,0x0);
175 ok((rc != 0),"InternetQueryDataAvailable failed");
180 buffer = (char*)HeapAlloc(GetProcessHeap(),0,length+1);
182 rc = InternetReadFile(hor,buffer,length,&length);
186 trace("ReadFile -> %li %li\n",rc,length);
188 HeapFree(GetProcessHeap(),0,buffer);
193 rc = InternetCloseHandle(hor);
194 ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed");
197 rc = InternetCloseHandle(hic);
198 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed");
201 rc = InternetCloseHandle(hi);
202 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed");
208 void InternetOpenUrlA_test(void)
210 HINTERNET myhinternet, myhttp;
212 URL_COMPONENTSA urlComponents;
213 char protocol[32], hostName[1024], userName[1024];
214 char password[1024], extra[1024], path[1024];
215 DWORD size, readbytes, totalbytes=0;
217 myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
218 ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
220 ok (InternetCanonicalizeUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz",buffer, &size,ICU_BROWSER_MODE),
221 "InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
223 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
224 urlComponents.lpszScheme = protocol;
225 urlComponents.dwSchemeLength = 32;
226 urlComponents.lpszHostName = hostName;
227 urlComponents.dwHostNameLength = 1024;
228 urlComponents.lpszUserName = userName;
229 urlComponents.dwUserNameLength = 1024;
230 urlComponents.lpszPassword = password;
231 urlComponents.dwPasswordLength = 1024;
232 urlComponents.lpszUrlPath = path;
233 urlComponents.dwUrlPathLength = 2048;
234 urlComponents.lpszExtraInfo = extra;
235 urlComponents.dwExtraInfoLength = 1024;
236 ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
237 "InternetCrackUrl failed, error %lx\n",GetLastError());
239 myhttp = InternetOpenUrl(myhinternet, "http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0, 0,
240 INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
241 if (GetLastError() == 12007)
242 return; /* WinXP returns this when not connected to the net */
243 ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
244 ok(InternetReadFile(myhttp, buffer,0x400,&readbytes), "InternetReadFile failed, error %lx\n",GetLastError());
245 totalbytes += readbytes;
246 while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
247 totalbytes += readbytes;
248 trace("read 0x%08lx bytes\n",totalbytes);
251 void InternetCrackUrl_test(void)
253 URL_COMPONENTSA urlComponents;
254 char protocol[32], hostName[1024], userName[1024];
255 char password[1024], extra[1024], path[1024];
257 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
258 urlComponents.lpszScheme = protocol;
259 urlComponents.dwSchemeLength = 32;
260 urlComponents.lpszHostName = hostName;
261 urlComponents.dwHostNameLength = 1024;
262 urlComponents.lpszUserName = userName;
263 urlComponents.dwUserNameLength = 1024;
264 urlComponents.lpszPassword = password;
265 urlComponents.dwPasswordLength = 1024;
266 urlComponents.lpszUrlPath = path;
267 urlComponents.dwUrlPathLength = 2048;
268 urlComponents.lpszExtraInfo = extra;
269 urlComponents.dwExtraInfoLength = 1024;
270 ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
271 "InternetCrackUrl failed, error %lx\n",GetLastError());
272 ok((strcmp("/fieldsync2/release.log.gz",path) == 0),"path cracked wrong");
277 winapi_test(0x10000000);
278 winapi_test(0x00000000);
279 InternetCrackUrl_test();
280 InternetOpenUrlA_test();