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");
128 rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0);
130 ok(((rc == 0)&&(GetLastError()==997)),
131 "Asyncronous HttpSendRequest NOT returning 0 with error 997");
133 ok((rc != 0), "Syncronous HttpSendRequest returning 0");
134 trace("HttpSendRequestA <--\n");
136 while ((flags)&&(!goon))
140 rc = InternetQueryOptionA(hor,0x17,&out,&length);
141 trace("Option 0x17 -> %li %li\n",rc,out);
144 rc = InternetQueryOptionA(hor,0x22,buffer,&length);
145 trace("Option 0x22 -> %li %s\n",rc,buffer);
148 rc = HttpQueryInfoA(hor,0x16,buffer,&length,0x0);
150 trace("Option 0x16 -> %li %s\n",rc,buffer);
153 rc = InternetQueryOptionA(hor,0x22,buffer,&length);
155 trace("Option 0x22 -> %li %s\n",rc,buffer);
158 rc = HttpQueryInfoA(hor,0x5,&buffer,&length,0x0);
159 trace("Option 0x5 -> %li %s (%li)\n",rc,buffer,GetLastError());
162 rc = HttpQueryInfoA(hor,0x1,buffer,&length,0x0);
164 trace("Option 0x1 -> %li %s\n",rc,buffer);
167 trace("Entery Query loop\n");
172 rc = InternetQueryDataAvailable(hor,&length,0x0,0x0);
173 ok((rc != 0),"InternetQueryDataAvailable failed");
178 buffer = (char*)HeapAlloc(GetProcessHeap(),0,length+1);
180 rc = InternetReadFile(hor,buffer,length,&length);
184 trace("ReadFile -> %li %li\n",rc,length);
186 HeapFree(GetProcessHeap(),0,buffer);
191 rc = InternetCloseHandle(hor);
192 ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed");
195 rc = InternetCloseHandle(hic);
196 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed");
199 rc = InternetCloseHandle(hi);
200 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed");
206 void InternetOpenUrlA_test(void)
208 HINTERNET myhinternet, myhttp;
210 URL_COMPONENTSA urlComponents;
211 char protocol[32], hostName[1024], userName[1024];
212 char password[1024], extra[1024], path[1024];
213 DWORD size, readbytes, totalbytes=0;
215 myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
216 ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
218 ok (InternetCanonicalizeUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz",buffer, &size,ICU_BROWSER_MODE),
219 "InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
221 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
222 urlComponents.lpszScheme = protocol;
223 urlComponents.dwSchemeLength = 32;
224 urlComponents.lpszHostName = hostName;
225 urlComponents.dwHostNameLength = 1024;
226 urlComponents.lpszUserName = userName;
227 urlComponents.dwUserNameLength = 1024;
228 urlComponents.lpszPassword = password;
229 urlComponents.dwPasswordLength = 1024;
230 urlComponents.lpszUrlPath = path;
231 urlComponents.dwUrlPathLength = 2048;
232 urlComponents.lpszExtraInfo = extra;
233 urlComponents.dwExtraInfoLength = 1024;
234 ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
235 "InternetCrackUrl failed, error %lx\n",GetLastError());
236 myhttp = InternetOpenUrl(myhinternet, "http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0, 0,
237 INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
238 ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
239 ok(InternetReadFile(myhttp, buffer,0x400,&readbytes), "InternetReadFile failed, error %lx\n",GetLastError());
240 totalbytes += readbytes;
241 while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
242 totalbytes += readbytes;
243 trace("read 0x%08lx bytes\n",totalbytes);
246 void InternetCrackUrl_test(void)
248 URL_COMPONENTSA urlComponents;
249 char protocol[32], hostName[1024], userName[1024];
250 char password[1024], extra[1024], path[1024];
252 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
253 urlComponents.lpszScheme = protocol;
254 urlComponents.dwSchemeLength = 32;
255 urlComponents.lpszHostName = hostName;
256 urlComponents.dwHostNameLength = 1024;
257 urlComponents.lpszUserName = userName;
258 urlComponents.dwUserNameLength = 1024;
259 urlComponents.lpszPassword = password;
260 urlComponents.dwPasswordLength = 1024;
261 urlComponents.lpszUrlPath = path;
262 urlComponents.dwUrlPathLength = 2048;
263 urlComponents.lpszExtraInfo = extra;
264 urlComponents.dwExtraInfoLength = 1024;
265 ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
266 "InternetCrackUrl failed, error %lx\n",GetLastError());
267 ok((strcmp("/fieldsync2/release.log.gz",path) == 0),"path cracked wrong");
272 winapi_test(0x10000000);
273 winapi_test(0x00000000);
274 InternetCrackUrl_test();
275 InternetOpenUrlA_test();