2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2002-06-22 01:59:49 +02:00
|
|
|
#include <stdio.h>
|
2002-10-29 22:24:35 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
2002-06-22 01:59:49 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wininet.h"
|
|
|
|
|
2002-10-29 22:24:35 +01:00
|
|
|
#include "wine/test.h"
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
int goon = 0;
|
|
|
|
|
|
|
|
VOID WINAPI callback(
|
|
|
|
HINTERNET hInternet,
|
|
|
|
DWORD dwContext,
|
|
|
|
DWORD dwInternetStatus,
|
|
|
|
LPVOID lpvStatusInformation,
|
|
|
|
DWORD dwStatusInformationLength
|
|
|
|
)
|
|
|
|
{
|
|
|
|
char name[124];
|
|
|
|
|
|
|
|
switch (dwInternetStatus)
|
|
|
|
{
|
|
|
|
case INTERNET_STATUS_RESOLVING_NAME:
|
|
|
|
strcpy(name,"INTERNET_STATUS_RESOLVING_NAME");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_NAME_RESOLVED:
|
|
|
|
strcpy(name,"INTERNET_STATUS_NAME_RESOLVED");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_CONNECTING_TO_SERVER:
|
|
|
|
strcpy(name,"INTERNET_STATUS_CONNECTING_TO_SERVER");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_CONNECTED_TO_SERVER:
|
|
|
|
strcpy(name,"INTERNET_STATUS_CONNECTED_TO_SERVER");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_SENDING_REQUEST:
|
|
|
|
strcpy(name,"INTERNET_STATUS_SENDING_REQUEST");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_REQUEST_SENT:
|
|
|
|
strcpy(name,"INTERNET_STATUS_REQUEST_SENT");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_RECEIVING_RESPONSE:
|
|
|
|
strcpy(name,"INTERNET_STATUS_RECEIVING_RESPONSE");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_RESPONSE_RECEIVED:
|
|
|
|
strcpy(name,"INTERNET_STATUS_RESPONSE_RECEIVED");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_CTL_RESPONSE_RECEIVED:
|
|
|
|
strcpy(name,"INTERNET_STATUS_CTL_RESPONSE_RECEIVED");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_PREFETCH:
|
|
|
|
strcpy(name,"INTERNET_STATUS_PREFETCH");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_CLOSING_CONNECTION:
|
|
|
|
strcpy(name,"INTERNET_STATUS_CLOSING_CONNECTION");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_CONNECTION_CLOSED:
|
|
|
|
strcpy(name,"INTERNET_STATUS_CONNECTION_CLOSED");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_HANDLE_CREATED:
|
|
|
|
strcpy(name,"INTERNET_STATUS_HANDLE_CREATED");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_HANDLE_CLOSING:
|
|
|
|
strcpy(name,"INTERNET_STATUS_HANDLE_CLOSING");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_REQUEST_COMPLETE:
|
|
|
|
strcpy(name,"INTERNET_STATUS_REQUEST_COMPLETE");
|
|
|
|
goon = 1;
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_REDIRECT:
|
|
|
|
strcpy(name,"INTERNET_STATUS_REDIRECT");
|
|
|
|
break;
|
|
|
|
case INTERNET_STATUS_INTERMEDIATE_RESPONSE:
|
|
|
|
strcpy(name,"INTERNET_STATUS_INTERMEDIATE_RESPONSE");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
trace("Callback %p 0x%lx %s(%li) %p %ld\n",hInternet,dwContext,name,dwInternetStatus,lpvStatusInformation,dwStatusInformationLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
void winapi_test(int flags)
|
|
|
|
{
|
|
|
|
DWORD rc;
|
|
|
|
CHAR buffer[4000];
|
|
|
|
DWORD length;
|
|
|
|
DWORD out;
|
2002-12-07 00:21:35 +01:00
|
|
|
const char *types[2] = { "*", NULL };
|
2002-12-17 22:03:33 +01:00
|
|
|
HINTERNET hi, hic = 0, hor = 0;
|
2002-06-22 01:59:49 +02:00
|
|
|
|
|
|
|
trace("Starting with flags 0x%x\n",flags);
|
|
|
|
|
|
|
|
trace("InternetOpenA <--\n");
|
|
|
|
hi = InternetOpenA("",0x0,0x0,0x0,flags);
|
|
|
|
ok((hi != 0x0),"InternetOpen Failed");
|
|
|
|
trace("InternetOpenA -->\n");
|
|
|
|
|
2002-10-09 20:12:20 +02:00
|
|
|
if (hi == 0x0) goto abort;
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
InternetSetStatusCallback(hi,&callback);
|
|
|
|
|
|
|
|
trace("InternetConnectA <--\n");
|
|
|
|
hic=InternetConnectA(hi,"www.winehq.com",0x0,0x0,0x0,0x3,0x0,0xdeadbeef);
|
|
|
|
ok((hic != 0x0),"InternetConnect Failed");
|
|
|
|
trace("InternetConnectA -->\n");
|
|
|
|
|
2002-10-09 20:12:20 +02:00
|
|
|
if (hic == 0x0) goto abort;
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
trace("HttpOpenRequestA <--\n");
|
|
|
|
hor = HttpOpenRequestA(hic, "GET",
|
|
|
|
"/about/",
|
2002-12-07 00:21:35 +01:00
|
|
|
0x0,0x0,types,0x00400800,0xdeadbead);
|
2002-10-09 20:12:20 +02:00
|
|
|
if (hor == 0x0 && GetLastError() == 12007 /* ERROR_INTERNET_NAME_NOT_RESOLVED */) {
|
|
|
|
/*
|
|
|
|
* If the internet name can't be resolved we are probably behind
|
|
|
|
* a firewall or in some other way not directly connected to the
|
|
|
|
* Internet. Not enough reason to fail the test. Just ignore and
|
|
|
|
* abort.
|
|
|
|
*/
|
|
|
|
} else {
|
|
|
|
ok((hor != 0x0),"HttpOpenRequest Failed");
|
|
|
|
}
|
2002-06-22 01:59:49 +02:00
|
|
|
trace("HttpOpenRequestA -->\n");
|
|
|
|
|
2002-10-09 20:12:20 +02:00
|
|
|
if (hor == 0x0) goto abort;
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
trace("HttpSendRequestA -->\n");
|
2003-09-25 22:29:40 +02:00
|
|
|
SetLastError(0);
|
2002-06-22 01:59:49 +02:00
|
|
|
rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0);
|
|
|
|
if (flags)
|
|
|
|
ok(((rc == 0)&&(GetLastError()==997)),
|
|
|
|
"Asyncronous HttpSendRequest NOT returning 0 with error 997");
|
|
|
|
else
|
2003-09-25 22:29:40 +02:00
|
|
|
ok((rc != 0) || GetLastError() == 12007, /* 12007 == XP */
|
|
|
|
"Syncronous HttpSendRequest returning 0, error %ld", GetLastError());
|
2002-06-22 01:59:49 +02:00
|
|
|
trace("HttpSendRequestA <--\n");
|
|
|
|
|
|
|
|
while ((flags)&&(!goon))
|
|
|
|
Sleep(100);
|
|
|
|
|
|
|
|
length = 4;
|
|
|
|
rc = InternetQueryOptionA(hor,0x17,&out,&length);
|
|
|
|
trace("Option 0x17 -> %li %li\n",rc,out);
|
|
|
|
|
|
|
|
length = 100;
|
|
|
|
rc = InternetQueryOptionA(hor,0x22,buffer,&length);
|
|
|
|
trace("Option 0x22 -> %li %s\n",rc,buffer);
|
|
|
|
|
|
|
|
length = 4000;
|
|
|
|
rc = HttpQueryInfoA(hor,0x16,buffer,&length,0x0);
|
|
|
|
buffer[length]=0;
|
|
|
|
trace("Option 0x16 -> %li %s\n",rc,buffer);
|
|
|
|
|
|
|
|
length = 4000;
|
|
|
|
rc = InternetQueryOptionA(hor,0x22,buffer,&length);
|
|
|
|
buffer[length]=0;
|
|
|
|
trace("Option 0x22 -> %li %s\n",rc,buffer);
|
|
|
|
|
|
|
|
length = 16;
|
|
|
|
rc = HttpQueryInfoA(hor,0x5,&buffer,&length,0x0);
|
|
|
|
trace("Option 0x5 -> %li %s (%li)\n",rc,buffer,GetLastError());
|
|
|
|
|
|
|
|
length = 100;
|
|
|
|
rc = HttpQueryInfoA(hor,0x1,buffer,&length,0x0);
|
|
|
|
buffer[length]=0;
|
|
|
|
trace("Option 0x1 -> %li %s\n",rc,buffer);
|
|
|
|
|
|
|
|
length = 100;
|
|
|
|
trace("Entery Query loop\n");
|
|
|
|
|
|
|
|
while (length)
|
|
|
|
{
|
|
|
|
|
|
|
|
rc = InternetQueryDataAvailable(hor,&length,0x0,0x0);
|
|
|
|
ok((rc != 0),"InternetQueryDataAvailable failed");
|
|
|
|
|
|
|
|
if (length)
|
|
|
|
{
|
|
|
|
char *buffer;
|
|
|
|
buffer = (char*)HeapAlloc(GetProcessHeap(),0,length+1);
|
|
|
|
|
|
|
|
rc = InternetReadFile(hor,buffer,length,&length);
|
|
|
|
|
|
|
|
buffer[length]=0;
|
|
|
|
|
|
|
|
trace("ReadFile -> %li %li\n",rc,length);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0,buffer);
|
|
|
|
}
|
|
|
|
}
|
2002-10-09 20:12:20 +02:00
|
|
|
abort:
|
|
|
|
if (hor != 0x0) {
|
|
|
|
rc = InternetCloseHandle(hor);
|
|
|
|
ok ((rc != 0), "InternetCloseHandle of handle opened by HttpOpenRequestA failed");
|
|
|
|
}
|
2002-12-17 22:03:33 +01:00
|
|
|
if (hic != 0x0) {
|
2002-10-09 20:12:20 +02:00
|
|
|
rc = InternetCloseHandle(hic);
|
|
|
|
ok ((rc != 0), "InternetCloseHandle of handle opened by InternetConnectA failed");
|
|
|
|
}
|
|
|
|
if (hi != 0x0) {
|
|
|
|
rc = InternetCloseHandle(hi);
|
|
|
|
ok ((rc != 0), "InternetCloseHandle of handle opened by InternetOpenA failed");
|
|
|
|
if (flags)
|
|
|
|
Sleep(100);
|
|
|
|
}
|
2002-06-22 01:59:49 +02:00
|
|
|
}
|
|
|
|
|
2003-02-25 04:57:59 +01:00
|
|
|
void InternetOpenUrlA_test(void)
|
|
|
|
{
|
|
|
|
HINTERNET myhinternet, myhttp;
|
|
|
|
char buffer[0x400];
|
|
|
|
URL_COMPONENTSA urlComponents;
|
|
|
|
char protocol[32], hostName[1024], userName[1024];
|
|
|
|
char password[1024], extra[1024], path[1024];
|
|
|
|
DWORD size, readbytes, totalbytes=0;
|
|
|
|
|
|
|
|
myhinternet = InternetOpen("Winetest",0,NULL,NULL,INTERNET_FLAG_NO_CACHE_WRITE);
|
|
|
|
ok((myhinternet != 0), "InternetOpen failed, error %lx\n",GetLastError());
|
|
|
|
size = 0x400;
|
|
|
|
ok (InternetCanonicalizeUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz",buffer, &size,ICU_BROWSER_MODE),
|
|
|
|
"InternetCanonicalizeUrl failed, error %lx\n",GetLastError());
|
|
|
|
|
|
|
|
urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
|
|
|
|
urlComponents.lpszScheme = protocol;
|
|
|
|
urlComponents.dwSchemeLength = 32;
|
|
|
|
urlComponents.lpszHostName = hostName;
|
|
|
|
urlComponents.dwHostNameLength = 1024;
|
|
|
|
urlComponents.lpszUserName = userName;
|
|
|
|
urlComponents.dwUserNameLength = 1024;
|
|
|
|
urlComponents.lpszPassword = password;
|
|
|
|
urlComponents.dwPasswordLength = 1024;
|
|
|
|
urlComponents.lpszUrlPath = path;
|
|
|
|
urlComponents.dwUrlPathLength = 2048;
|
|
|
|
urlComponents.lpszExtraInfo = extra;
|
|
|
|
urlComponents.dwExtraInfoLength = 1024;
|
|
|
|
ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
|
|
|
|
"InternetCrackUrl failed, error %lx\n",GetLastError());
|
2003-09-25 22:29:40 +02:00
|
|
|
SetLastError(0);
|
2003-02-25 04:57:59 +01:00
|
|
|
myhttp = InternetOpenUrl(myhinternet, "http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0, 0,
|
|
|
|
INTERNET_FLAG_RELOAD|INTERNET_FLAG_NO_CACHE_WRITE|INTERNET_FLAG_TRANSFER_BINARY,0);
|
2003-09-25 22:29:40 +02:00
|
|
|
if (GetLastError() == 12007)
|
|
|
|
return; /* WinXP returns this when not connected to the net */
|
2003-02-25 04:57:59 +01:00
|
|
|
ok((myhttp != 0),"InternetOpenUrl failed, error %lx\n",GetLastError());
|
|
|
|
ok(InternetReadFile(myhttp, buffer,0x400,&readbytes), "InternetReadFile failed, error %lx\n",GetLastError());
|
|
|
|
totalbytes += readbytes;
|
|
|
|
while (readbytes && InternetReadFile(myhttp, buffer,0x400,&readbytes))
|
|
|
|
totalbytes += readbytes;
|
2003-07-22 05:16:47 +02:00
|
|
|
trace("read 0x%08lx bytes\n",totalbytes);
|
2003-02-25 04:57:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InternetCrackUrl_test(void)
|
|
|
|
{
|
|
|
|
URL_COMPONENTSA urlComponents;
|
|
|
|
char protocol[32], hostName[1024], userName[1024];
|
|
|
|
char password[1024], extra[1024], path[1024];
|
|
|
|
|
|
|
|
urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
|
|
|
|
urlComponents.lpszScheme = protocol;
|
|
|
|
urlComponents.dwSchemeLength = 32;
|
|
|
|
urlComponents.lpszHostName = hostName;
|
|
|
|
urlComponents.dwHostNameLength = 1024;
|
|
|
|
urlComponents.lpszUserName = userName;
|
|
|
|
urlComponents.dwUserNameLength = 1024;
|
|
|
|
urlComponents.lpszPassword = password;
|
|
|
|
urlComponents.dwPasswordLength = 1024;
|
|
|
|
urlComponents.lpszUrlPath = path;
|
|
|
|
urlComponents.dwUrlPathLength = 2048;
|
|
|
|
urlComponents.lpszExtraInfo = extra;
|
|
|
|
urlComponents.dwExtraInfoLength = 1024;
|
|
|
|
ok((InternetCrackUrl("http://LTspice.linear-tech.com/fieldsync2/release.log.gz", 0,0,&urlComponents)),
|
|
|
|
"InternetCrackUrl failed, error %lx\n",GetLastError());
|
|
|
|
ok((strcmp("/fieldsync2/release.log.gz",path) == 0),"path cracked wrong");
|
|
|
|
}
|
2002-06-22 01:59:49 +02:00
|
|
|
|
|
|
|
START_TEST(http)
|
|
|
|
{
|
|
|
|
winapi_test(0x10000000);
|
|
|
|
winapi_test(0x00000000);
|
2003-02-25 04:57:59 +01:00
|
|
|
InternetCrackUrl_test();
|
|
|
|
InternetOpenUrlA_test();
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
}
|