Reworking of http and asyncronous calls to get IE6 to install.

Added a version resource.
Added unit test for http.
This commit is contained in:
Aric Stewart 2002-06-21 23:59:49 +00:00 committed by Alexandre Julliard
parent e35580f4c9
commit ff9b9d4ef8
13 changed files with 680 additions and 162 deletions

5
configure vendored
View file

@ -13079,6 +13079,8 @@ ac_config_commands="$ac_config_commands dlls/user/tests"
ac_config_commands="$ac_config_commands dlls/wineps/data" ac_config_commands="$ac_config_commands dlls/wineps/data"
ac_config_commands="$ac_config_commands dlls/wininet/tests"
ac_config_commands="$ac_config_commands dlls/winsock/tests" ac_config_commands="$ac_config_commands dlls/winsock/tests"
ac_config_commands="$ac_config_commands files" ac_config_commands="$ac_config_commands files"
@ -13760,6 +13762,7 @@ do
"dlls/user/resources" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/user/resources" ;; "dlls/user/resources" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/user/resources" ;;
"dlls/user/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/user/tests" ;; "dlls/user/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/user/tests" ;;
"dlls/wineps/data" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/wineps/data" ;; "dlls/wineps/data" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/wineps/data" ;;
"dlls/wininet/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/wininet/tests" ;;
"dlls/winsock/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/winsock/tests" ;; "dlls/winsock/tests" ) CONFIG_COMMANDS="$CONFIG_COMMANDS dlls/winsock/tests" ;;
"files" ) CONFIG_COMMANDS="$CONFIG_COMMANDS files" ;; "files" ) CONFIG_COMMANDS="$CONFIG_COMMANDS files" ;;
"graphics" ) CONFIG_COMMANDS="$CONFIG_COMMANDS graphics" ;; "graphics" ) CONFIG_COMMANDS="$CONFIG_COMMANDS graphics" ;;
@ -14458,6 +14461,8 @@ echo "$as_me: creating dlls/user/resources" >&6;} && mkdir "dlls/user/resources"
echo "$as_me: creating dlls/user/tests" >&6;} && mkdir "dlls/user/tests") ;; echo "$as_me: creating dlls/user/tests" >&6;} && mkdir "dlls/user/tests") ;;
dlls/wineps/data ) test -d "dlls/wineps/data" || ({ echo "$as_me:$LINENO: creating dlls/wineps/data" >&5 dlls/wineps/data ) test -d "dlls/wineps/data" || ({ echo "$as_me:$LINENO: creating dlls/wineps/data" >&5
echo "$as_me: creating dlls/wineps/data" >&6;} && mkdir "dlls/wineps/data") ;; echo "$as_me: creating dlls/wineps/data" >&6;} && mkdir "dlls/wineps/data") ;;
dlls/wininet/tests ) test -d "dlls/wininet/tests" || ({ echo "$as_me:$LINENO: creating dlls/wininet/tests" >&5
echo "$as_me: creating dlls/wininet/tests" >&6;} && mkdir "dlls/wininet/tests") ;;
dlls/winsock/tests ) test -d "dlls/winsock/tests" || ({ echo "$as_me:$LINENO: creating dlls/winsock/tests" >&5 dlls/winsock/tests ) test -d "dlls/winsock/tests" || ({ echo "$as_me:$LINENO: creating dlls/winsock/tests" >&5
echo "$as_me: creating dlls/winsock/tests" >&6;} && mkdir "dlls/winsock/tests") ;; echo "$as_me: creating dlls/winsock/tests" >&6;} && mkdir "dlls/winsock/tests") ;;
files ) test -d "files" || ({ echo "$as_me:$LINENO: creating files" >&5 files ) test -d "files" || ({ echo "$as_me:$LINENO: creating files" >&5

View file

@ -1200,6 +1200,7 @@ WINE_CONFIG_EXTRA_DIR(dlls/user/dde)
WINE_CONFIG_EXTRA_DIR(dlls/user/resources) WINE_CONFIG_EXTRA_DIR(dlls/user/resources)
WINE_CONFIG_EXTRA_DIR(dlls/user/tests) WINE_CONFIG_EXTRA_DIR(dlls/user/tests)
WINE_CONFIG_EXTRA_DIR(dlls/wineps/data) WINE_CONFIG_EXTRA_DIR(dlls/wineps/data)
WINE_CONFIG_EXTRA_DIR(dlls/wininet/tests)
WINE_CONFIG_EXTRA_DIR(dlls/winsock/tests) WINE_CONFIG_EXTRA_DIR(dlls/winsock/tests)
WINE_CONFIG_EXTRA_DIR(files) WINE_CONFIG_EXTRA_DIR(files)
WINE_CONFIG_EXTRA_DIR(graphics) WINE_CONFIG_EXTRA_DIR(graphics)

View file

@ -1,3 +1,4 @@
Makefile Makefile
version.res
wininet.dll.dbg.c wininet.dll.dbg.c
wininet.spec.c wininet.spec.c

View file

@ -17,6 +17,14 @@ C_SRCS = \
utility.c \ utility.c \
wininet_main.c wininet_main.c
RC_SRCS= \
version.rc
CTESTS = \
tests/http.c
EXTRASUBDIRS = tests
@MAKE_DLL_RULES@ @MAKE_DLL_RULES@
### Dependencies: ### Dependencies:

View file

@ -2,8 +2,10 @@
* Wininet - Http Implementation * Wininet - Http Implementation
* *
* Copyright 1999 Corel Corporation * Copyright 1999 Corel Corporation
* Copyright 2002 CodeWeavers Inc.
* *
* Ulrich Czekalla * Ulrich Czekalla
* Aric Stewart
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -105,6 +107,8 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
BOOL bSuccess = FALSE; BOOL bSuccess = FALSE;
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hHttpRequest; LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hHttpRequest;
TRACE("\n");
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ) if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
{ {
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
@ -167,10 +171,19 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE); INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE; return FALSE;
} }
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent; hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) /*
* My tests seem to show that the windows version does not
* become asynchronous until after this point. And anyhow
* if this call was asynchronous then how would you get the
* necessary HINTERNET pointer returned by this function.
*
* I am leaving this here just in case I am wrong
*
* if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
*/
if (0)
{ {
WORKREQUEST workRequest; WORKREQUEST workRequest;
@ -178,13 +191,20 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
workRequest.HFTPSESSION = (DWORD)hHttpSession; workRequest.HFTPSESSION = (DWORD)hHttpSession;
workRequest.LPSZVERB = (DWORD)HTTP_strdup(lpszVerb); workRequest.LPSZVERB = (DWORD)HTTP_strdup(lpszVerb);
workRequest.LPSZOBJECTNAME = (DWORD)HTTP_strdup(lpszObjectName); workRequest.LPSZOBJECTNAME = (DWORD)HTTP_strdup(lpszObjectName);
workRequest.LPSZVERSION = (DWORD)HTTP_strdup(lpszVersion); if (lpszVersion)
workRequest.LPSZREFERRER = (DWORD)HTTP_strdup(lpszReferrer); workRequest.LPSZVERSION = (DWORD)HTTP_strdup(lpszVersion);
else
workRequest.LPSZVERSION = 0;
if (lpszReferrer)
workRequest.LPSZREFERRER = (DWORD)HTTP_strdup(lpszReferrer);
else
workRequest.LPSZREFERRER = 0;
workRequest.LPSZACCEPTTYPES = (DWORD)lpszAcceptTypes; workRequest.LPSZACCEPTTYPES = (DWORD)lpszAcceptTypes;
workRequest.DWFLAGS = dwFlags; workRequest.DWFLAGS = dwFlags;
workRequest.DWCONTEXT = dwContext; workRequest.DWCONTEXT = dwContext;
return (HINTERNET)INTERNET_AsyncCall(&workRequest); INTERNET_AsyncCall(&workRequest);
return NULL;
} }
else else
{ {
@ -213,7 +233,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
LPWININETAPPINFOA hIC = NULL; LPWININETAPPINFOA hIC = NULL;
LPWININETHTTPREQA lpwhr; LPWININETHTTPREQA lpwhr;
TRACE("\n"); TRACE("--> \n");
if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION) if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION)
{ {
@ -238,10 +258,18 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
if (NULL != lpszObjectName && strlen(lpszObjectName)) { if (NULL != lpszObjectName && strlen(lpszObjectName)) {
DWORD needed = 0; DWORD needed = 0;
UrlEscapeA(lpszObjectName, NULL, &needed, URL_ESCAPE_SPACES_ONLY); HRESULT rc;
rc = UrlEscapeA(lpszObjectName, NULL, &needed, URL_ESCAPE_SPACES_ONLY);
if (rc != E_POINTER)
needed = strlen(lpszObjectName)+1;
lpwhr->lpszPath = HeapAlloc(GetProcessHeap(), 0, needed); lpwhr->lpszPath = HeapAlloc(GetProcessHeap(), 0, needed);
UrlEscapeA(lpszObjectName, lpwhr->lpszPath, &needed, rc = UrlEscapeA(lpszObjectName, lpwhr->lpszPath, &needed,
URL_ESCAPE_SPACES_ONLY); URL_ESCAPE_SPACES_ONLY);
if (rc)
{
ERR("Unable to escape string!(%s) (%ld)\n",lpszObjectName,rc);
strcpy(lpwhr->lpszPath,lpszObjectName);
}
} }
if (NULL != lpszReferrer && strlen(lpszReferrer)) if (NULL != lpszReferrer && strlen(lpszReferrer))
@ -283,20 +311,36 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
iar.dwResult = (DWORD)lpwhr; iar.dwResult = (DWORD)lpwhr;
iar.dwError = ERROR_SUCCESS; iar.dwError = ERROR_SUCCESS;
hIC->lpfnStatusCB(hHttpSession, dwContext, INTERNET_STATUS_HANDLE_CREATED, SendAsyncCallback(hIC, hHttpSession, dwContext,
&iar, sizeof(INTERNET_ASYNC_RESULT)); INTERNET_STATUS_HANDLE_CREATED, &iar,
sizeof(INTERNET_ASYNC_RESULT));
} }
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) /*
* A STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on windows
*/
/*
* According to my tests. The name is not resolved until a request is Opened
*/
SendAsyncCallback(hIC, hHttpSession, dwContext,
INTERNET_STATUS_RESOLVING_NAME,
lpwhs->lpszServerName,
strlen(lpwhs->lpszServerName)+1);
if (!GetAddress(lpwhs->lpszServerName, lpwhs->nServerPort,
&lpwhs->phostent, &lpwhs->socketAddress))
{ {
INTERNET_ASYNC_RESULT iar; INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
return FALSE;
iar.dwResult = (DWORD)lpwhr;
iar.dwError = lpwhr ? ERROR_SUCCESS : INTERNET_GetLastError();
hIC->lpfnStatusCB(hHttpSession, dwContext, INTERNET_STATUS_REQUEST_COMPLETE,
&iar, sizeof(INTERNET_ASYNC_RESULT));
} }
SendAsyncCallback(hIC, hHttpSession, lpwhr->hdr.dwContext,
INTERNET_STATUS_NAME_RESOLVED,
&(lpwhs->socketAddress),
sizeof(struct sockaddr_in));
TRACE("<--\n");
return (HINTERNET) lpwhr; return (HINTERNET) lpwhr;
} }
@ -367,7 +411,6 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
strlen(lpwhr->StdHeaders[i].lpszValue) + delim + 2; strlen(lpwhr->StdHeaders[i].lpszValue) + delim + 2;
} }
} }
size += delim; size += delim;
if (size + 1 > *lpdwBufferLength) if (size + 1 > *lpdwBufferLength)
@ -475,6 +518,7 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
} }
strncpy(lpBuffer, lphttpHdr->lpszValue, len); strncpy(lpBuffer, lphttpHdr->lpszValue, len);
((char*)lpBuffer)[len]=0;
*lpdwBufferLength = len; *lpdwBufferLength = len;
bSuccess = TRUE; bSuccess = TRUE;
} }
@ -544,14 +588,22 @@ BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
{ {
WORKREQUEST workRequest; WORKREQUEST workRequest;
workRequest.asyncall = HTTPSENDREQUESTA; workRequest.asyncall = HTTPSENDREQUESTA;
workRequest.HFTPSESSION = (DWORD)hHttpRequest; workRequest.HFTPSESSION = (DWORD)hHttpRequest;
workRequest.LPSZHEADER = (DWORD)HTTP_strdup(lpszHeaders); if (lpszHeaders)
workRequest.DWHEADERLENGTH = dwHeaderLength; workRequest.LPSZHEADER = (DWORD)HTTP_strdup(lpszHeaders);
workRequest.LPOPTIONAL = (DWORD)lpOptional; else
workRequest.DWOPTIONALLENGTH = dwOptionalLength; workRequest.LPSZHEADER = 0;
workRequest.DWHEADERLENGTH = dwHeaderLength;
workRequest.LPOPTIONAL = (DWORD)lpOptional;
workRequest.DWOPTIONALLENGTH = dwOptionalLength;
return INTERNET_AsyncCall(&workRequest); INTERNET_AsyncCall(&workRequest);
/*
* This is from windows. I do not know what the name is
*/
SetLastError(0x3e5);
return 0;
} }
else else
{ {
@ -579,12 +631,13 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
BOOL bSuccess = FALSE; BOOL bSuccess = FALSE;
LPSTR requestString = NULL; LPSTR requestString = NULL;
INT requestStringLen; INT requestStringLen;
INT responseLen;
INT headerLength = 0; INT headerLength = 0;
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hHttpRequest; LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hHttpRequest;
LPWININETHTTPSESSIONA lpwhs = NULL; LPWININETHTTPSESSIONA lpwhs = NULL;
LPWININETAPPINFOA hIC = NULL; LPWININETAPPINFOA hIC = NULL;
TRACE("0x%08lx\n", (ULONG)hHttpRequest); TRACE("--> 0x%08lx\n", (ULONG)hHttpRequest);
/* Verify our tree of internet handles */ /* Verify our tree of internet handles */
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ) if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
@ -610,6 +663,7 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
/* Clear any error information */ /* Clear any error information */
INTERNET_SetLastError(0); INTERNET_SetLastError(0);
/* We must have a verb */ /* We must have a verb */
if (NULL == lpwhr->lpszVerb) if (NULL == lpwhr->lpszVerb)
{ {
@ -711,35 +765,50 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
/* Set termination string for request */ /* Set termination string for request */
strcpy(requestString + cnt, "\r\n\r\n"); strcpy(requestString + cnt, "\r\n\r\n");
if (hIC->lpfnStatusCB)
hIC->lpfnStatusCB(hHttpRequest, lpwhr->hdr.dwContext, INTERNET_STATUS_SENDING_REQUEST, NULL, 0);
TRACE("(%s) len(%d)\n", requestString, requestStringLen); TRACE("(%s) len(%d)\n", requestString, requestStringLen);
/* Send the request and store the results */ /* Send the request and store the results */
if (!HTTP_OpenConnection(lpwhr)) if (!HTTP_OpenConnection(lpwhr))
goto lend; goto lend;
cnt = INTERNET_WriteDataToStream(lpwhr->nSocketFD, requestString, requestStringLen); SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
INTERNET_STATUS_SENDING_REQUEST, NULL, 0);
cnt = send(lpwhr->nSocketFD, requestString, requestStringLen, 0);
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
INTERNET_STATUS_REQUEST_SENT,
&requestStringLen,sizeof(DWORD));
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0);
if (cnt < 0) if (cnt < 0)
goto lend; goto lend;
if (HTTP_GetResponseHeaders(lpwhr)) responseLen = HTTP_GetResponseHeaders(lpwhr);
if (responseLen)
bSuccess = TRUE; bSuccess = TRUE;
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
INTERNET_STATUS_RESPONSE_RECEIVED, &responseLen,
sizeof(DWORD));
lend: lend:
if (requestString) if (requestString)
HeapFree(GetProcessHeap(), 0, requestString); HeapFree(GetProcessHeap(), 0, requestString);
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB)
if (hIC->lpfnStatusCB)
{ {
INTERNET_ASYNC_RESULT iar; INTERNET_ASYNC_RESULT iar;
iar.dwResult = (DWORD)bSuccess; iar.dwResult = (DWORD)bSuccess;
iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError();
hIC->lpfnStatusCB(hHttpRequest, lpwhr->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE,
&iar, sizeof(INTERNET_ASYNC_RESULT)); SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
sizeof(INTERNET_ASYNC_RESULT));
} }
TRACE("<--\n"); TRACE("<--\n");
@ -765,12 +834,13 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
LPWININETAPPINFOA hIC = NULL; LPWININETAPPINFOA hIC = NULL;
LPWININETHTTPSESSIONA lpwhs = NULL; LPWININETHTTPSESSIONA lpwhs = NULL;
TRACE("\n"); TRACE("-->\n");
if (((LPWININETHANDLEHEADER)hInternet)->htype != WH_HINIT) if (((LPWININETHANDLEHEADER)hInternet)->htype != WH_HINIT)
goto lerror; goto lerror;
hIC = (LPWININETAPPINFOA) hInternet; hIC = (LPWININETAPPINFOA) hInternet;
hIC->hdr.dwContext = dwContext;
lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONA)); lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONA));
if (NULL == lpwhs) if (NULL == lpwhs)
@ -779,23 +849,13 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
goto lerror; goto lerror;
} }
if (hIC->lpfnStatusCB) /*
hIC->lpfnStatusCB(hInternet, dwContext, INTERNET_STATUS_RESOLVING_NAME, * According to my tests. The name is not resolved until a request is sent
(LPVOID)lpszServerName, strlen(lpszServerName)); */
if (nServerPort == INTERNET_INVALID_PORT_NUMBER) if (nServerPort == INTERNET_INVALID_PORT_NUMBER)
nServerPort = INTERNET_DEFAULT_HTTP_PORT; nServerPort = INTERNET_DEFAULT_HTTP_PORT;
if (!GetAddress(lpszServerName, nServerPort, &lpwhs->phostent, &lpwhs->socketAddress))
{
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
goto lerror;
}
if (hIC->lpfnStatusCB)
hIC->lpfnStatusCB(hInternet, dwContext, INTERNET_STATUS_NAME_RESOLVED,
(LPVOID)lpszServerName, strlen(lpszServerName));
lpwhs->hdr.htype = WH_HHTTPSESSION; lpwhs->hdr.htype = WH_HHTTPSESSION;
lpwhs->hdr.lpwhparent = (LPWININETHANDLEHEADER)hInternet; lpwhs->hdr.lpwhparent = (LPWININETHANDLEHEADER)hInternet;
lpwhs->hdr.dwFlags = dwFlags; lpwhs->hdr.dwFlags = dwFlags;
@ -813,8 +873,9 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
iar.dwResult = (DWORD)lpwhs; iar.dwResult = (DWORD)lpwhs;
iar.dwError = ERROR_SUCCESS; iar.dwError = ERROR_SUCCESS;
hIC->lpfnStatusCB(hInternet, dwContext, INTERNET_STATUS_HANDLE_CREATED, SendAsyncCallback(hIC, hInternet, dwContext,
&iar, sizeof(INTERNET_ASYNC_RESULT)); INTERNET_STATUS_HANDLE_CREATED, &iar,
sizeof(INTERNET_ASYNC_RESULT));
} }
bSuccess = TRUE; bSuccess = TRUE;
@ -826,15 +887,11 @@ lerror:
lpwhs = NULL; lpwhs = NULL;
} }
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) /*
{ * a INTERNET_STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on
INTERNET_ASYNC_RESULT iar; * windows
*/
iar.dwResult = (DWORD)lpwhs;
iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError();
hIC->lpfnStatusCB(hInternet, dwContext, INTERNET_STATUS_REQUEST_COMPLETE,
&iar, sizeof(INTERNET_ASYNC_RESULT));
}
TRACE("<--\n"); TRACE("<--\n");
return (HINTERNET)lpwhs; return (HINTERNET)lpwhs;
} }
@ -855,8 +912,10 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQA lpwhr)
BOOL bSuccess = FALSE; BOOL bSuccess = FALSE;
INT result; INT result;
LPWININETHTTPSESSIONA lpwhs; LPWININETHTTPSESSIONA lpwhs;
LPWININETAPPINFOA hIC = NULL;
TRACE("-->\n");
TRACE("\n");
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ) if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
{ {
@ -866,6 +925,12 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQA lpwhr)
lpwhs = (LPWININETHTTPSESSIONA)lpwhr->hdr.lpwhparent; lpwhs = (LPWININETHTTPSESSIONA)lpwhr->hdr.lpwhparent;
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CONNECTING_TO_SERVER,
&(lpwhs->socketAddress),
sizeof(struct sockaddr_in));
lpwhr->nSocketFD = socket(lpwhs->phostent->h_addrtype,SOCK_STREAM,0); lpwhr->nSocketFD = socket(lpwhs->phostent->h_addrtype,SOCK_STREAM,0);
if (lpwhr->nSocketFD == -1) if (lpwhr->nSocketFD == -1)
{ {
@ -882,10 +947,15 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQA lpwhr)
goto lend; goto lend;
} }
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CONNECTED_TO_SERVER,
&(lpwhs->socketAddress),
sizeof(struct sockaddr_in));
bSuccess = TRUE; bSuccess = TRUE;
lend: lend:
TRACE(": %d\n", bSuccess); TRACE("%d <--\n", bSuccess);
return bSuccess; return bSuccess;
} }
@ -906,16 +976,23 @@ BOOL HTTP_GetResponseHeaders(LPWININETHTTPREQA lpwhr)
CHAR buffer[MAX_REPLY_LEN]; CHAR buffer[MAX_REPLY_LEN];
DWORD buflen = MAX_REPLY_LEN; DWORD buflen = MAX_REPLY_LEN;
BOOL bSuccess = FALSE; BOOL bSuccess = FALSE;
INT rc = 0;
CHAR value[MAX_FIELD_VALUE_LEN], field[MAX_FIELD_LEN]; CHAR value[MAX_FIELD_VALUE_LEN], field[MAX_FIELD_LEN];
TRACE("\n"); TRACE("-->\n");
if (lpwhr->nSocketFD == -1) if (lpwhr->nSocketFD == -1)
goto lend; goto lend;
/*
* HACK peek at the buffer
*/
rc = recv(lpwhr->nSocketFD,buffer,buflen,MSG_PEEK);
/* /*
* We should first receive 'HTTP/1.x nnn' where nnn is the status code. * We should first receive 'HTTP/1.x nnn' where nnn is the status code.
*/ */
buflen = MAX_REPLY_LEN;
if (!INTERNET_GetNextLine(lpwhr->nSocketFD, buffer, &buflen)) if (!INTERNET_GetNextLine(lpwhr->nSocketFD, buffer, &buflen))
goto lend; goto lend;
@ -948,7 +1025,11 @@ BOOL HTTP_GetResponseHeaders(LPWININETHTTPREQA lpwhr)
lend: lend:
return bSuccess; TRACE("<--\n");
if (bSuccess)
return rc;
else
return FALSE;
} }
@ -1066,7 +1147,7 @@ INT HTTP_GetStdHeaderIndex(LPCSTR lpszField)
index = HTTP_QUERY_USER_AGENT; index = HTTP_QUERY_USER_AGENT;
else else
{ {
FIXME("Couldn't find %s in standard header table\n", lpszField); TRACE("Couldn't find %s in standard header table\n", lpszField);
} }
return index; return index;
@ -1088,7 +1169,7 @@ BOOL HTTP_ProcessHeader(LPWININETHTTPREQA lpwhr, LPCSTR field, LPCSTR value, DWO
BOOL bSuccess = FALSE; BOOL bSuccess = FALSE;
INT index; INT index;
TRACE("%s:%s - 0x%08x\n", field, value, (unsigned int)dwModifier); TRACE("--> %s:%s - 0x%08x\n", field, value, (unsigned int)dwModifier);
/* Adjust modifier flags */ /* Adjust modifier flags */
if (dwModifier & COALESCEFLASG) if (dwModifier & COALESCEFLASG)
@ -1102,29 +1183,29 @@ BOOL HTTP_ProcessHeader(LPWININETHTTPREQA lpwhr, LPCSTR field, LPCSTR value, DWO
} }
else /* Find or create new custom header */ else /* Find or create new custom header */
{ {
index = HTTP_GetCustomHeaderIndex(lpwhr, field); index = HTTP_GetCustomHeaderIndex(lpwhr, field);
if (index >= 0) if (index >= 0)
{ {
if (dwModifier & HTTP_ADDHDR_FLAG_ADD_IF_NEW) if (dwModifier & HTTP_ADDHDR_FLAG_ADD_IF_NEW)
{ {
return FALSE; return FALSE;
} }
lphttpHdr = &lpwhr->pCustHeaders[index]; lphttpHdr = &lpwhr->pCustHeaders[index];
} }
else else
{ {
HTTPHEADERA hdr; HTTPHEADERA hdr;
hdr.lpszField = (LPSTR)field; hdr.lpszField = (LPSTR)field;
hdr.lpszValue = (LPSTR)value; hdr.lpszValue = (LPSTR)value;
hdr.wFlags = hdr.wCount = 0; hdr.wFlags = hdr.wCount = 0;
if (dwModifier & HTTP_ADDHDR_FLAG_REQ) if (dwModifier & HTTP_ADDHDR_FLAG_REQ)
hdr.wFlags |= HDR_ISREQUEST; hdr.wFlags |= HDR_ISREQUEST;
index = HTTP_InsertCustomHeader(lpwhr, &hdr); index = HTTP_InsertCustomHeader(lpwhr, &hdr);
return index >= 0; return index >= 0;
} }
} }
if (dwModifier & HTTP_ADDHDR_FLAG_REQ) if (dwModifier & HTTP_ADDHDR_FLAG_REQ)
@ -1228,7 +1309,7 @@ BOOL HTTP_ProcessHeader(LPWININETHTTPREQA lpwhr, LPCSTR field, LPCSTR value, DWO
} }
} }
} }
TRACE("<--\n");
return bSuccess; return bSuccess;
} }
@ -1241,11 +1322,27 @@ BOOL HTTP_ProcessHeader(LPWININETHTTPREQA lpwhr, LPCSTR field, LPCSTR value, DWO
*/ */
VOID HTTP_CloseConnection(LPWININETHTTPREQA lpwhr) VOID HTTP_CloseConnection(LPWININETHTTPREQA lpwhr)
{ {
LPWININETHTTPSESSIONA lpwhs = NULL;
LPWININETAPPINFOA hIC = NULL;
TRACE("%p\n",lpwhr);
lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
if (lpwhr->nSocketFD != -1) if (lpwhr->nSocketFD != -1)
{ {
close(lpwhr->nSocketFD); close(lpwhr->nSocketFD);
lpwhr->nSocketFD = -1; lpwhr->nSocketFD = -1;
} }
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
INTERNET_STATUS_CONNECTION_CLOSED, 0, 0);
} }
@ -1258,12 +1355,21 @@ VOID HTTP_CloseConnection(LPWININETHTTPREQA lpwhr)
void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr) void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr)
{ {
int i; int i;
LPWININETHTTPSESSIONA lpwhs = NULL;
LPWININETAPPINFOA hIC = NULL;
TRACE("\n"); TRACE("\n");
if (lpwhr->nSocketFD != -1) if (lpwhr->nSocketFD != -1)
HTTP_CloseConnection(lpwhr); HTTP_CloseConnection(lpwhr);
lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
INTERNET_STATUS_HANDLE_CLOSING, lpwhr,
sizeof(HINTERNET));
if (lpwhr->lpszPath) if (lpwhr->lpszPath)
HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath); HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);
if (lpwhr->lpszVerb) if (lpwhr->lpszVerb)
@ -1300,8 +1406,15 @@ void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr)
*/ */
void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs) void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs)
{ {
LPWININETAPPINFOA hIC = NULL;
TRACE("\n"); TRACE("\n");
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
SendAsyncCallback(hIC, lpwhs, lpwhs->hdr.dwContext,
INTERNET_STATUS_HANDLE_CLOSING, lpwhs,
sizeof(HINTERNET));
if (lpwhs->lpszServerName) if (lpwhs->lpszServerName)
HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName); HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName);
if (lpwhs->lpszUserName) if (lpwhs->lpszUserName)
@ -1348,7 +1461,7 @@ INT HTTP_InsertCustomHeader(LPWININETHTTPREQA lpwhr, LPHTTPHEADERA lpHdr)
INT count; INT count;
LPHTTPHEADERA lph = NULL; LPHTTPHEADERA lph = NULL;
TRACE("%s: %s\n", lpHdr->lpszField, lpHdr->lpszValue); TRACE("--> %s: %s\n", lpHdr->lpszField, lpHdr->lpszValue);
count = lpwhr->nCustHeaders + 1; count = lpwhr->nCustHeaders + 1;
if (count > 1) if (count > 1)
lph = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpwhr->pCustHeaders, sizeof(HTTPHEADERA) * count); lph = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lpwhr->pCustHeaders, sizeof(HTTPHEADERA) * count);
@ -1383,6 +1496,6 @@ INT HTTP_InsertCustomHeader(LPWININETHTTPREQA lpwhr, LPHTTPHEADERA lpHdr)
*/ */
BOOL HTTP_DeleteCustomHeader(INT index) BOOL HTTP_DeleteCustomHeader(INT index)
{ {
TRACE("\n"); FIXME("STUB\n");
return FALSE; return FALSE;
} }

View file

@ -2,8 +2,10 @@
* Wininet * Wininet
* *
* Copyright 1999 Corel Corporation * Copyright 1999 Corel Corporation
* Copyright 2002 CodeWeavers Inc.
* *
* Ulrich Czekalla * Ulrich Czekalla
* Aric Stewart
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -267,7 +269,7 @@ HINTERNET WINAPI InternetConnectA(HINTERNET hInternet,
{ {
HINTERNET rc = (HINTERNET) NULL; HINTERNET rc = (HINTERNET) NULL;
TRACE("\n"); TRACE("ServerPort %i\n",nServerPort);
/* Clear any error information */ /* Clear any error information */
INTERNET_SetLastError(0); INTERNET_SetLastError(0);
@ -387,15 +389,17 @@ BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
lend: lend:
hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh); hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB) if (hIC->lpfnStatusCB)
{ {
INTERNET_ASYNC_RESULT iar; INTERNET_ASYNC_RESULT iar;
iar.dwResult = (DWORD)bSuccess; iar.dwResult = (DWORD)bSuccess;
iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError(); iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
INTERNET_GetLastError();
hIC->lpfnStatusCB(hFind, lpwh->hdr.dwContext, INTERNET_STATUS_REQUEST_COMPLETE, SendAsyncCallback(hIC, hFind, lpwh->hdr.dwContext,
&iar, sizeof(INTERNET_ASYNC_RESULT)); INTERNET_STATUS_REQUEST_COMPLETE, &iar,
sizeof(INTERNET_ASYNC_RESULT));
} }
return bSuccess; return bSuccess;
@ -413,6 +417,12 @@ lend:
*/ */
VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai) VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai)
{ {
TRACE("%p\n",lpwai);
SendAsyncCallback(lpwai, lpwai, lpwai->hdr.dwContext,
INTERNET_STATUS_HANDLE_CLOSING, lpwai,
sizeof(HINTERNET));
if (lpwai->lpszAgent) if (lpwai->lpszAgent)
HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent); HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
@ -441,7 +451,7 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
BOOL retval = FALSE; BOOL retval = FALSE;
LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hInternet; LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hInternet;
TRACE("\n"); TRACE("%p\n",hInternet);
if (NULL == lpwh) if (NULL == lpwh)
return FALSE; return FALSE;
@ -672,6 +682,8 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
if (lpszPort != lpszNetLoc) if (lpszPort != lpszNetLoc)
lpUrlComponents->nPort = atoi(++lpszPort); lpUrlComponents->nPort = atoi(++lpszPort);
else
lpUrlComponents->nPort = 0;
} }
} }
@ -851,11 +863,9 @@ BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
if (nSocket != -1) if (nSocket != -1)
{ {
*lpdwNumOfBytesWritten = INTERNET_WriteDataToStream(nSocket, lpBuffer, dwNumOfBytesToWrite); int res = send(nSocket, lpBuffer, dwNumOfBytesToWrite, 0);
if (*lpdwNumOfBytesWritten < 0) retval = (res >= 0);
*lpdwNumOfBytesWritten = 0; *lpdwNumOfBytesWritten = retval ? res : 0;
else
retval = TRUE;
} }
return retval; return retval;
@ -880,6 +890,7 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile; LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
TRACE("\n"); TRACE("\n");
if (NULL == lpwh) if (NULL == lpwh)
return FALSE; return FALSE;
@ -899,13 +910,10 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
if (nSocket != -1) if (nSocket != -1)
{ {
*dwNumOfBytesRead = INTERNET_ReadDataFromStream(nSocket, lpBuffer, dwNumOfBytesToRead); int res = recv(nSocket, lpBuffer, dwNumOfBytesToRead, 0);
if (*dwNumOfBytesRead < 0) retval = (res >= 0);
*dwNumOfBytesRead = 0; *dwNumOfBytesRead = retval ? res : 0;
else
retval = TRUE;
} }
return retval; return retval;
} }
@ -938,25 +946,72 @@ BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
switch (dwOption) switch (dwOption)
{ {
case INTERNET_OPTION_HANDLE_TYPE: case INTERNET_OPTION_HANDLE_TYPE:
{
ULONG type = lpwhh->htype;
TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type);
if (*lpdwBufferLength < sizeof(ULONG))
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
memcpy(lpBuffer, &type, sizeof(ULONG));
*lpdwBufferLength = sizeof(ULONG);
bSuccess = TRUE;
}
break;
}
case INTERNET_OPTION_REQUEST_FLAGS:
{
ULONG flags = 4;
TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags);
if (*lpdwBufferLength < sizeof(ULONG))
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
memcpy(lpBuffer, &flags, sizeof(ULONG));
*lpdwBufferLength = sizeof(ULONG);
bSuccess = TRUE;
}
break;
}
case INTERNET_OPTION_URL:
case INTERNET_OPTION_DATAFILE_NAME:
{
ULONG type = lpwhh->htype;
if (type == WH_HHTTPREQ)
{
LPWININETHTTPREQA lpreq = hInternet;
char url[1023];
sprintf(url,"http://%s%s",lpreq->lpszHostName,lpreq->lpszPath);
TRACE("INTERNET_OPTION_URL: %s\n",url);
if (*lpdwBufferLength < strlen(url)+1)
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
else
{
memcpy(lpBuffer, url, strlen(url)+1);
*lpdwBufferLength = strlen(url)+1;
bSuccess = TRUE;
}
}
break;
}
case INTERNET_OPTION_HTTP_VERSION:
{ {
ULONG type = lpwhh->htype; /*
TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type); * Presently hardcoded to 1.1
*/
if (*lpdwBufferLength < sizeof(ULONG)) ((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); ((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
else bSuccess = TRUE;
{ break;
memcpy(lpBuffer, &type, sizeof(ULONG));
*lpdwBufferLength = sizeof(ULONG);
bSuccess = TRUE;
}
break;
} }
default: default:
FIXME("Stub!\n"); FIXME("Stub! %ld \n",dwOption);
break; break;
} }
@ -1069,6 +1124,7 @@ BOOL WINAPI InternetSetCookieA(
*/ */
INTERNET_SCHEME GetInternetScheme(LPCSTR lpszScheme, INT nMaxCmp) INTERNET_SCHEME GetInternetScheme(LPCSTR lpszScheme, INT nMaxCmp)
{ {
TRACE("\n");
if(lpszScheme==NULL) if(lpszScheme==NULL)
return INTERNET_SCHEME_UNKNOWN; return INTERNET_SCHEME_UNKNOWN;
@ -1114,6 +1170,8 @@ BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwRes
char host[1024]; char host[1024];
int status = -1; int status = -1;
FIXME("\n");
/* /*
* Crack or set the Address * Crack or set the Address
*/ */
@ -1243,43 +1301,6 @@ HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl, LPCSTR lp
InternetCloseHandle(client); InternetCloseHandle(client);
} }
/***********************************************************************
* INTERNET_WriteDataToStream (internal)
*
* Send data to server
*
* RETURNS
*
* number of characters sent on success
* -1 on error
*/
int INTERNET_WriteDataToStream(int nDataSocket, LPCVOID Buffer, DWORD BytesToWrite)
{
if (nDataSocket == -1)
return -1;
return send(nDataSocket, Buffer, BytesToWrite, 0);
}
/***********************************************************************
* INTERNET_ReadDataFromStream (internal)
*
* Read data from http server
*
* RETURNS
*
* number of characters sent on success
* -1 on error
*/
int INTERNET_ReadDataFromStream(int nDataSocket, LPVOID Buffer, DWORD BytesToRead)
{
if (nDataSocket == -1)
return -1;
return recv(nDataSocket, Buffer, BytesToRead, 0);
}
/*********************************************************************** /***********************************************************************
* INTERNET_SetLastError (internal) * INTERNET_SetLastError (internal)
@ -1581,6 +1602,12 @@ VOID INTERNET_ExecuteWork()
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZREFERRER); HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZREFERRER);
break; break;
case SENDCALLBACK:
SendAsyncCallbackInt((LPWININETAPPINFOA)workRequest.param1,
(HINTERNET)workRequest.param2, workRequest.param3,
workRequest.param4, (LPVOID)workRequest.param5,
workRequest.param6);
break;
} }
} }
} }
@ -1595,6 +1622,7 @@ VOID INTERNET_ExecuteWork()
LPSTR INTERNET_GetResponseBuffer() LPSTR INTERNET_GetResponseBuffer()
{ {
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex); LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
TRACE("\n");
return lpwite->response; return lpwite->response;
} }
@ -1662,3 +1690,70 @@ lend:
return NULL; return NULL;
} }
} }
/***********************************************************************
*
*/
BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
LPDWORD lpdwNumberOfBytesAvailble,
DWORD dwFlags, DWORD dwConext)
{
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hFile;
INT retval = -1;
int nSocket = -1;
if (NULL == lpwhr)
{
SetLastError(ERROR_NO_MORE_FILES);
return FALSE;
}
TRACE("--> %p %i %i\n",lpwhr,lpwhr->hdr.htype,lpwhr->nSocketFD);
switch (lpwhr->hdr.htype)
{
case WH_HHTTPREQ:
nSocket = lpwhr->nSocketFD;
break;
default:
break;
}
if (nSocket != -1)
{
char buffer[4048];
retval = recv(nSocket,buffer,4048,MSG_PEEK);
}
else
{
SetLastError(ERROR_NO_MORE_FILES);
}
if (lpdwNumberOfBytesAvailble)
{
(*lpdwNumberOfBytesAvailble) = retval;
}
TRACE("<-- %i\n",retval);
return (retval+1);
}
/***********************************************************************
*
*/
BOOL WINAPI InternetLockRequestFile( HINTERNET hInternet, HANDLE
*lphLockReqHandle)
{
FIXME("STUB\n");
return FALSE;
}
BOOL WINAPI InternetUnlockRequestFile( HANDLE hLockHandle)
{
FIXME("STUB\n");
return FALSE;
}

View file

@ -154,6 +154,7 @@ typedef enum
INTERNETFINDNEXTA, INTERNETFINDNEXTA,
HTTPSENDREQUESTA, HTTPSENDREQUESTA,
HTTPOPENREQUESTA, HTTPOPENREQUESTA,
SENDCALLBACK,
} ASYNC_FUNC; } ASYNC_FUNC;
typedef struct WORKREQ typedef struct WORKREQ
@ -220,8 +221,6 @@ HINTERNET HTTP_Connect(HINTERNET hInterent, LPCSTR lpszServerName,
BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort, BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
struct hostent **phe, struct sockaddr_in *psa); struct hostent **phe, struct sockaddr_in *psa);
int INTERNET_WriteDataToStream(int nDataSocket, LPCVOID Buffer, DWORD BytesToWrite);
int INTERNET_ReadDataFromStream(int nDataSocket, LPVOID Buffer, DWORD BytesToRead);
void INTERNET_SetLastError(DWORD dwError); void INTERNET_SetLastError(DWORD dwError);
DWORD INTERNET_GetLastError(); DWORD INTERNET_GetLastError();
BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest); BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
@ -257,6 +256,14 @@ INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs); void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs);
void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr); void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr);
VOID SendAsyncCallback(LPWININETAPPINFOA hIC, HINTERNET hHttpSession,
DWORD dwContext, DWORD dwInternetStatus, LPVOID
lpvStatusInfo , DWORD dwStatusInfoLength);
VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession,
DWORD dwContext, DWORD dwInternetStatus, LPVOID
lpvStatusInfo , DWORD dwStatusInfoLength);
#define MAX_REPLY_LEN 0x5B4 #define MAX_REPLY_LEN 0x5B4

View file

@ -0,0 +1,3 @@
http.ok
testlist.c
wininet_test.exe.spec.c

186
dlls/wininet/tests/http.c Normal file
View file

@ -0,0 +1,186 @@
#include <stdio.h>
#include "winbase.h"
#include "wininet.h"
#include "wine/test.h"
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;
char *types;
HINTERNET hi,hic,hor;
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");
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");
types = (char*)malloc(100);
strcpy(types,"*");
trace("HttpOpenRequestA <--\n");
hor = HttpOpenRequestA(hic, "GET",
"/about/",
0x0,0x0,(const char**)&types,0x00400800,0xdeadbead);
ok((hor != 0x0),"HttpOpenRequest Failed");
trace("HttpOpenRequestA -->\n");
trace("HttpSendRequestA -->\n");
rc = HttpSendRequestA(hor, "", 0xffffffff,0x0,0x0);
if (flags)
ok(((rc == 0)&&(GetLastError()==997)),
"Asyncronous HttpSendRequest NOT returning 0 with error 997");
else
ok((rc != 0), "Syncronous HttpSendRequest returning 0");
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);
}
}
rc = InternetCloseHandle(hi);
ok ((rc != 0), "InternetCloseHandle failed");
rc = InternetCloseHandle(hor);
ok ((rc != 0), "InternetCloseHandle failed");
if (flags)
Sleep(100);
}
START_TEST(http)
{
winapi_test(0x10000000);
winapi_test(0x00000000);
}

View file

@ -1,9 +1,10 @@
/* /*
* Wininet - Url Cache functions * Wininet - Url Cache functions
* *
* Copyright 2001 CodeWeavers * Copyright 2001,2002 CodeWeavers
* *
* Eric Kohl * Eric Kohl
* Aric Stewart
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -39,11 +40,29 @@ WINE_DEFAULT_DEBUG_CHANNEL(wininet);
INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA(LPCSTR lpszUrlSearchPattern, INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryA(LPCSTR lpszUrlSearchPattern,
LPINTERNET_CACHE_ENTRY_INFOA lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize) LPINTERNET_CACHE_ENTRY_INFOA lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize)
{ {
FIXME("STUB\n");
return 0; return 0;
} }
INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW(LPCWSTR lpszUrlSearchPattern, INTERNETAPI HANDLE WINAPI FindFirstUrlCacheEntryW(LPCWSTR lpszUrlSearchPattern,
LPINTERNET_CACHE_ENTRY_INFOW lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize) LPINTERNET_CACHE_ENTRY_INFOW lpFirstCacheEntryInfo, LPDWORD lpdwFirstCacheEntryInfoBufferSize)
{ {
FIXME("STUB\n");
return 0; return 0;
} }
BOOL WINAPI RetrieveUrlCacheEntryFileA (LPCSTR lpszUrlName,
LPINTERNET_CACHE_ENTRY_INFOA lpCacheEntryInfo, LPDWORD
lpdwCacheEntryInfoBufferSize, DWORD dwReserved)
{
FIXME("STUB\n");
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}
BOOL WINAPI DeleteUrlCacheEntry(LPCSTR lpszUrlName)
{
FIXME("STUB (%s)\n",lpszUrlName);
SetLastError(ERROR_FILE_NOT_FOUND);
return FALSE;
}

View file

@ -2,8 +2,10 @@
* Wininet - Utility functions * Wininet - Utility functions
* *
* Copyright 1999 Corel Corporation * Copyright 1999 Corel Corporation
* Copyright 2002 CodeWeavers Inc.
* *
* Ulrich Czekalla * Ulrich Czekalla
* Aric Stewart
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -161,3 +163,52 @@ BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
return TRUE; return TRUE;
} }
/*
* Helper function for sending async Callbacks
*/
VOID SendAsyncCallbackInt(LPWININETAPPINFOA hIC, HINTERNET hHttpSession,
DWORD dwContext, DWORD dwInternetStatus, LPVOID
lpvStatusInfo, DWORD dwStatusInfoLength)
{
if (! (hIC->lpfnStatusCB))
return;
TRACE("--> Callback %ld\n",dwInternetStatus);
hIC->lpfnStatusCB(hHttpSession, dwContext, dwInternetStatus,
lpvStatusInfo, dwStatusInfoLength);
TRACE("<-- Callback %ld\n",dwInternetStatus);
}
VOID SendAsyncCallback(LPWININETAPPINFOA hIC, HINTERNET hHttpSession,
DWORD dwContext, DWORD dwInternetStatus, LPVOID
lpvStatusInfo, DWORD dwStatusInfoLength)
{
TRACE("Send Callback %ld\n",dwInternetStatus);
if (! (hIC->lpfnStatusCB))
return;
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
{
WORKREQUEST workRequest;
workRequest.asyncall = SENDCALLBACK;
workRequest.param1 = (DWORD)hIC;
workRequest.param2 = (DWORD)hHttpSession;
workRequest.param3 = dwContext;
workRequest.param4 = dwInternetStatus;
workRequest.param5 = (DWORD)lpvStatusInfo;
workRequest.param6 = dwStatusInfoLength;
INTERNET_AsyncCall(&workRequest);
}
else
SendAsyncCallbackInt(hIC, hHttpSession, dwContext, dwInternetStatus,
lpvStatusInfo, dwStatusInfoLength);
}

29
dlls/wininet/version.rc Normal file
View file

@ -0,0 +1,29 @@
/*
* Copyright 2002 CodeWeavers
*
* Aric Stewart
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define WINE_FILEDESCRIPTION_STR "Wine WinInet"
#define WINE_FILENAME_STR "wininet.dll"
#define WINE_FILEVERSION 5,0,0,0
#define WINE_FILEVERSION_STR "5.0.0.0"
#define WINE_PRODUCTVERSION 5,0,0,0
#define WINE_PRODUCTVERSION_STR "5.0"
#define WINE_PRODUCTNAME_STR "wininet"
#include "wine/wine_common_ver.rc"

View file

@ -12,7 +12,7 @@ init WININET_LibMain
@ stub DeleteIE3Cache @ stub DeleteIE3Cache
@ stub DeleteUrlCacheContainerA @ stub DeleteUrlCacheContainerA
@ stub DeleteUrlCacheContainerW @ stub DeleteUrlCacheContainerW
@ stub DeleteUrlCacheEntry @ stdcall DeleteUrlCacheEntry(str) DeleteUrlCacheEntry
@ stub DeleteUrlCacheGroup @ stub DeleteUrlCacheGroup
@ stdcall DllInstall(long ptr) WININET_DllInstall @ stdcall DllInstall(long ptr) WININET_DllInstall
@ stub FindCloseUrlCache @ stub FindCloseUrlCache
@ -111,13 +111,13 @@ init WININET_LibMain
@ stub InternetGetLastResponseInfoW @ stub InternetGetLastResponseInfoW
@ stub InternetGoOnline @ stub InternetGoOnline
@ stub InternetHangUp @ stub InternetHangUp
@ stub InternetLockRequestFile @ stdcall InternetLockRequestFile(ptr ptr) InternetLockRequestFile
@ stdcall InternetOpenA(str long str str long) InternetOpenA @ stdcall InternetOpenA(str long str str long) InternetOpenA
@ stub InternetOpenServerPushParse @ stub InternetOpenServerPushParse
@ stdcall InternetOpenUrlA(ptr str str long long long) InternetOpenUrlA @ stdcall InternetOpenUrlA(ptr str str long long long) InternetOpenUrlA
@ stub InternetOpenUrlW @ stub InternetOpenUrlW
@ stub InternetOpenW @ stub InternetOpenW
@ stub InternetQueryDataAvailable @ stdcall InternetQueryDataAvailable(ptr ptr long long) InternetQueryDataAvailable
@ stdcall InternetQueryOptionA(ptr long ptr ptr) InternetQueryOptionA @ stdcall InternetQueryOptionA(ptr long ptr ptr) InternetQueryOptionA
@ stub InternetQueryOptionW @ stub InternetQueryOptionW
@ stdcall InternetReadFile(ptr ptr long ptr) InternetReadFile @ stdcall InternetReadFile(ptr ptr long ptr) InternetReadFile
@ -136,7 +136,7 @@ init WININET_LibMain
@ stub InternetShowSecurityInfoByURL @ stub InternetShowSecurityInfoByURL
@ stub InternetTimeFromSystemTime @ stub InternetTimeFromSystemTime
@ stub InternetTimeToSystemTime @ stub InternetTimeToSystemTime
@ stub InternetUnlockRequestFile @ stdcall InternetUnlockRequestFile(ptr) InternetUnlockRequestFile
@ stdcall InternetWriteFile(ptr ptr long ptr) InternetWriteFile @ stdcall InternetWriteFile(ptr ptr long ptr) InternetWriteFile
@ stub InternetWriteFileExA @ stub InternetWriteFileExA
@ stub InternetWriteFileExW @ stub InternetWriteFileExW
@ -144,7 +144,7 @@ init WININET_LibMain
@ stub LoadUrlCacheContent @ stub LoadUrlCacheContent
@ stub ParseX509EncodedCertificateForListBoxEntry @ stub ParseX509EncodedCertificateForListBoxEntry
@ stub ReadUrlCacheEntryStream @ stub ReadUrlCacheEntryStream
@ stub RetrieveUrlCacheEntryFileA @ stdcall RetrieveUrlCacheEntryFileA(str ptr ptr long) RetrieveUrlCacheEntryFileA
@ stub RetrieveUrlCacheEntryFileW @ stub RetrieveUrlCacheEntryFileW
@ stub RetrieveUrlCacheEntryStreamA @ stub RetrieveUrlCacheEntryStreamA
@ stub RetrieveUrlCacheEntryStreamW @ stub RetrieveUrlCacheEntryStreamW