15 DWORD dwInternetStatus,
16 LPVOID lpvStatusInformation,
17 DWORD dwStatusInformationLength
22 switch (dwInternetStatus)
24 case INTERNET_STATUS_RESOLVING_NAME:
25 strcpy(name,"INTERNET_STATUS_RESOLVING_NAME");
27 case INTERNET_STATUS_NAME_RESOLVED:
28 strcpy(name,"INTERNET_STATUS_NAME_RESOLVED");
30 case INTERNET_STATUS_CONNECTING_TO_SERVER:
31 strcpy(name,"INTERNET_STATUS_CONNECTING_TO_SERVER");
33 case INTERNET_STATUS_CONNECTED_TO_SERVER:
34 strcpy(name,"INTERNET_STATUS_CONNECTED_TO_SERVER");
36 case INTERNET_STATUS_SENDING_REQUEST:
37 strcpy(name,"INTERNET_STATUS_SENDING_REQUEST");
39 case INTERNET_STATUS_REQUEST_SENT:
40 strcpy(name,"INTERNET_STATUS_REQUEST_SENT");
42 case INTERNET_STATUS_RECEIVING_RESPONSE:
43 strcpy(name,"INTERNET_STATUS_RECEIVING_RESPONSE");
45 case INTERNET_STATUS_RESPONSE_RECEIVED:
46 strcpy(name,"INTERNET_STATUS_RESPONSE_RECEIVED");
48 case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
49 strcpy(name,"INTERNET_STATUS_CTL_RESPONSE_RECEIVED");
51 case INTERNET_STATUS_PREFETCH:
52 strcpy(name,"INTERNET_STATUS_PREFETCH");
54 case INTERNET_STATUS_CLOSING_CONNECTION:
55 strcpy(name,"INTERNET_STATUS_CLOSING_CONNECTION");
57 case INTERNET_STATUS_CONNECTION_CLOSED:
58 strcpy(name,"INTERNET_STATUS_CONNECTION_CLOSED");
60 case INTERNET_STATUS_HANDLE_CREATED:
61 strcpy(name,"INTERNET_STATUS_HANDLE_CREATED");
63 case INTERNET_STATUS_HANDLE_CLOSING:
64 strcpy(name,"INTERNET_STATUS_HANDLE_CLOSING");
66 case INTERNET_STATUS_REQUEST_COMPLETE:
67 strcpy(name,"INTERNET_STATUS_REQUEST_COMPLETE");
70 case INTERNET_STATUS_REDIRECT:
71 strcpy(name,"INTERNET_STATUS_REDIRECT");
73 case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
74 strcpy(name,"INTERNET_STATUS_INTERMEDIATE_RESPONSE");
78 trace("Callback %p 0x%lx %s(%li) %p %ld\n",hInternet,dwContext,name,dwInternetStatus,lpvStatusInformation,dwStatusInformationLength);
81 void winapi_test(int flags)
87 const char *types[2] = { "*", NULL };
88 HINTERNET hi, hic = 0, hor = 0;
90 trace("Starting with flags 0x%x\n",flags);
92 trace("InternetOpenA <--\n");
93 hi = InternetOpenA("",0x0,0x0,0x0,flags);
94 ok((hi != 0x0),"InternetOpen Failed");
95 trace("InternetOpenA -->\n");
97 if (hi == 0x0) goto abort;
99 InternetSetStatusCallback(hi,&callback);
101 trace("InternetConnectA <--\n");
102 hic=InternetConnectA(hi,"www.winehq.com",0x0,0x0,0x0,0x3,0x0,0xdeadbeef);
103 ok((hic != 0x0),"InternetConnect Failed");
104 trace("InternetConnectA -->\n");
106 if (hic == 0x0) goto abort;
108 trace("HttpOpenRequestA <--\n");
109 hor = HttpOpenRequestA(hic, "GET",
111 0x0,0x0,types,0x00400800,0xdeadbead);
112 if (hor == 0x0 && GetLastError() == 12007 /* ERROR_INTERNET_NAME_NOT_RESOLVED */) {
114 * If the internet name can't be resolved we are probably behind
115 * a firewall or in some other way not directly connected to the
116 * Internet. Not enough reason to fail the test. Just ignore and
120 ok((hor != 0x0),"HttpOpenRequest Failed");
122 trace("HttpOpenRequestA -->\n");
124 if (hor == 0x0) goto abort;
126 trace("HttpSendRequestA -->\n");
127 rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0);
129 ok(((rc == 0)&&(GetLastError()==997)),
130 "Asyncronous HttpSendRequest NOT returning 0 with error 997");
132 ok((rc != 0), "Syncronous HttpSendRequest returning 0");
133 trace("HttpSendRequestA <--\n");
135 while ((flags)&&(!goon))
139 rc = InternetQueryOptionA(hor,0x17,&out,&length);
140 trace("Option 0x17 -> %li %li\n",rc,out);
143 rc = InternetQueryOptionA(hor,0x22,buffer,&length);
144 trace("Option 0x22 -> %li %s\n",rc,buffer);
147 rc = HttpQueryInfoA(hor,0x16,buffer,&length,0x0);
149 trace("Option 0x16 -> %li %s\n",rc,buffer);
152 rc = InternetQueryOptionA(hor,0x22,buffer,&length);
154 trace("Option 0x22 -> %li %s\n",rc,buffer);
157 rc = HttpQueryInfoA(hor,0x5,&buffer,&length,0x0);
158 trace("Option 0x5 -> %li %s (%li)\n",rc,buffer,GetLastError());
161 rc = HttpQueryInfoA(hor,0x1,buffer,&length,0x0);
163 trace("Option 0x1 -> %li %s\n",rc,buffer);
166 trace("Entery Query loop\n");
171 rc = InternetQueryDataAvailable(hor,&length,0x0,0x0);
172 ok((rc != 0),"InternetQueryDataAvailable failed");
177 buffer = (char*)HeapAlloc(GetProcessHeap(),0,length+1);
179 rc = InternetReadFile(hor,buffer,length,&length);
183 trace("ReadFile -> %li %li\n",rc,length);
185 HeapFree(GetProcessHeap(),0,buffer);
190 rc = InternetCloseHandle(hor);
191 ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed");
194 rc = InternetCloseHandle(hic);
195 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed");
198 rc = InternetCloseHandle(hi);
199 ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed");
205 void InternetOpenUrlA_test(void)
207 HINTERNET myhinternet, myhttp;
209 URL_COMPONENTSA urlComponents;
210 char protocol[32], hostName[1024], userName[1024];
211 char password[1024], extra[1024], path[1024];
212 DWORD size, readbytes, totalbytes=0;
214 myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
215 ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
217 ok (InternetCanonicalizeUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz",buffer, &size,ICU_BROWSER_MODE),
218 "InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
220 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
221 urlComponents.lpszScheme = protocol;
222 urlComponents.dwSchemeLength = 32;
223 urlComponents.lpszHostName = hostName;
224 urlComponents.dwHostNameLength = 1024;
225 urlComponents.lpszUserName = userName;
226 urlComponents.dwUserNameLength = 1024;
227 urlComponents.lpszPassword = password;
228 urlComponents.dwPasswordLength = 1024;
229 urlComponents.lpszUrlPath = path;
230 urlComponents.dwUrlPathLength = 2048;
231 urlComponents.lpszExtraInfo = extra;
232 urlComponents.dwExtraInfoLength = 1024;
233 ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
234 "InternetCrackUrl failed, error %lx\n",GetLastError());
235 myhttp = InternetOpenUrl(myhinternet, "http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0, 0,
236 INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
237 ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
238 ok(InternetReadFile(myhttp, buffer,0x400,&readbytes), "InternetReadFile failed, error %lx\n",GetLastError());
239 totalbytes += readbytes;
240 while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
241 totalbytes += readbytes;
242 printf("read 0x%08lx bytes\n",totalbytes);
245 void InternetCrackUrl_test(void)
247 URL_COMPONENTSA urlComponents;
248 char protocol[32], hostName[1024], userName[1024];
249 char password[1024], extra[1024], path[1024];
251 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
252 urlComponents.lpszScheme = protocol;
253 urlComponents.dwSchemeLength = 32;
254 urlComponents.lpszHostName = hostName;
255 urlComponents.dwHostNameLength = 1024;
256 urlComponents.lpszUserName = userName;
257 urlComponents.dwUserNameLength = 1024;
258 urlComponents.lpszPassword = password;
259 urlComponents.dwPasswordLength = 1024;
260 urlComponents.lpszUrlPath = path;
261 urlComponents.dwUrlPathLength = 2048;
262 urlComponents.lpszExtraInfo = extra;
263 urlComponents.dwExtraInfoLength = 1024;
264 ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
265 "InternetCrackUrl failed, error %lx\n",GetLastError());
266 ok((strcmp("/fieldsync2/release.log.gz",path) == 0),"path cracked wrong");
271 winapi_test(0x10000000);
272 winapi_test(0x00000000);
273 InternetCrackUrl_test();
274 InternetOpenUrlA_test();