mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 10:41:12 +00:00
Use pointers internally and refcount all objects.
This commit is contained in:
parent
4104c622af
commit
3a1391b8dd
5 changed files with 542 additions and 517 deletions
File diff suppressed because it is too large
Load diff
|
@ -40,6 +40,7 @@
|
|||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
|
@ -81,6 +82,8 @@ static const WCHAR g_szUserAgent[] = {'U','s','e','r','-','A','g','e','n','t',0}
|
|||
#define HTTP_ADDHDR_FLAG_REQ 0x02000000
|
||||
|
||||
|
||||
static void HTTP_CloseHTTPRequestHandle(LPWININETHANDLEHEADER hdr);
|
||||
static void HTTP_CloseHTTPSessionHandle(LPWININETHANDLEHEADER hdr);
|
||||
BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr);
|
||||
int HTTP_WriteDataToStream(LPWININETHTTPREQW lpwhr,
|
||||
void *Buffer, int BytesToWrite);
|
||||
|
@ -230,9 +233,12 @@ BOOL WINAPI HttpAddRequestHeadersW(HINTERNET hHttpRequest,
|
|||
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return bSuccess;
|
||||
goto lend;
|
||||
}
|
||||
bSuccess = HTTP_HttpAddRequestHeadersW( lpwhr, lpszHeader, dwHeaderLength, dwModifier );
|
||||
lend:
|
||||
if( lpwhr )
|
||||
WININET_Release( &lpwhr->hdr );
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
@ -338,7 +344,7 @@ HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession,
|
|||
if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return NULL;
|
||||
goto lend;
|
||||
}
|
||||
hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
|
||||
|
||||
|
@ -348,40 +354,13 @@ HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession,
|
|||
* 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;
|
||||
struct WORKREQ_HTTPOPENREQUESTW *req;
|
||||
|
||||
workRequest.asyncall = HTTPOPENREQUESTW;
|
||||
workRequest.handle = hHttpSession;
|
||||
req = &workRequest.u.HttpOpenRequestW;
|
||||
req->lpszVerb = WININET_strdupW(lpszVerb);
|
||||
req->lpszObjectName = WININET_strdupW(lpszObjectName);
|
||||
if (lpszVersion)
|
||||
req->lpszVersion = WININET_strdupW(lpszVersion);
|
||||
else
|
||||
req->lpszVersion = 0;
|
||||
if (lpszReferrer)
|
||||
req->lpszReferrer = WININET_strdupW(lpszReferrer);
|
||||
else
|
||||
req->lpszReferrer = 0;
|
||||
req->lpszAcceptTypes = lpszAcceptTypes;
|
||||
req->dwFlags = dwFlags;
|
||||
req->dwContext = dwContext;
|
||||
|
||||
INTERNET_AsyncCall(&workRequest);
|
||||
}
|
||||
else
|
||||
{
|
||||
handle = HTTP_HttpOpenRequestW(hHttpSession, lpszVerb, lpszObjectName,
|
||||
lpszVersion, lpszReferrer, lpszAcceptTypes,
|
||||
dwFlags, dwContext);
|
||||
}
|
||||
handle = HTTP_HttpOpenRequestW(lpwhs, lpszVerb, lpszObjectName,
|
||||
lpszVersion, lpszReferrer, lpszAcceptTypes,
|
||||
dwFlags, dwContext);
|
||||
lend:
|
||||
if( lpwhs )
|
||||
WININET_Release( &lpwhs->hdr );
|
||||
TRACE("returning %p\n", handle);
|
||||
return handle;
|
||||
}
|
||||
|
@ -671,50 +650,45 @@ static BOOL HTTP_DealWithProxy( LPWININETAPPINFOW hIC,
|
|||
* NULL on failure
|
||||
*
|
||||
*/
|
||||
HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
|
||||
HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
|
||||
LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
|
||||
LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
|
||||
DWORD dwFlags, DWORD dwContext)
|
||||
{
|
||||
LPWININETHTTPSESSIONW lpwhs;
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
LPWININETHTTPREQW lpwhr;
|
||||
LPWSTR lpszCookies;
|
||||
LPWSTR lpszUrl = NULL;
|
||||
DWORD nCookieSize;
|
||||
HINTERNET handle;
|
||||
HINTERNET handle = NULL;
|
||||
static const WCHAR szUrlForm[] = {'h','t','t','p',':','/','/','%','s',0};
|
||||
DWORD len;
|
||||
|
||||
TRACE("--> \n");
|
||||
|
||||
lpwhs = (LPWININETHTTPSESSIONW) WININET_GetObject( hHttpSession );
|
||||
if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
assert( lpwhs->hdr.htype == WH_HHTTPSESSION );
|
||||
hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
|
||||
|
||||
lpwhr = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPREQW));
|
||||
if (NULL == lpwhr)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
||||
return NULL;
|
||||
goto lend;
|
||||
}
|
||||
lpwhr->hdr.htype = WH_HHTTPREQ;
|
||||
lpwhr->hdr.lpwhparent = WININET_AddRef( &lpwhs->hdr );
|
||||
lpwhr->hdr.dwFlags = dwFlags;
|
||||
lpwhr->hdr.dwContext = dwContext;
|
||||
lpwhr->hdr.dwRefCount = 1;
|
||||
lpwhr->hdr.destroy = HTTP_CloseHTTPRequestHandle;
|
||||
|
||||
handle = WININET_AllocHandle( &lpwhr->hdr );
|
||||
if (NULL == handle)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
||||
HeapFree( GetProcessHeap(), 0, lpwhr );
|
||||
return NULL;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
lpwhr->hdr.htype = WH_HHTTPREQ;
|
||||
lpwhr->hdr.lpwhparent = &lpwhs->hdr;
|
||||
lpwhr->hdr.dwFlags = dwFlags;
|
||||
lpwhr->hdr.dwContext = dwContext;
|
||||
NETCON_init(&lpwhr->netConnection, dwFlags & INTERNET_FLAG_SECURE);
|
||||
|
||||
if (NULL != lpszObjectName && strlenW(lpszObjectName)) {
|
||||
|
@ -817,7 +791,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
|
|||
iar.dwResult = (DWORD)handle;
|
||||
iar.dwError = ERROR_SUCCESS;
|
||||
|
||||
SendAsyncCallback(hIC, hHttpSession, dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhs->hdr, dwContext,
|
||||
INTERNET_STATUS_HANDLE_CREATED, &iar,
|
||||
sizeof(INTERNET_ASYNC_RESULT));
|
||||
}
|
||||
|
@ -829,7 +803,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
|
|||
/*
|
||||
* According to my tests. The name is not resolved until a request is Opened
|
||||
*/
|
||||
SendAsyncCallback(hIC, hHttpSession, dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhs->hdr, dwContext,
|
||||
INTERNET_STATUS_RESOLVING_NAME,
|
||||
lpwhs->lpszServerName,
|
||||
strlenW(lpwhs->lpszServerName)+1);
|
||||
|
@ -837,15 +811,21 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
|
|||
&lpwhs->phostent, &lpwhs->socketAddress))
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
|
||||
return NULL;
|
||||
InternetCloseHandle( handle );
|
||||
handle = NULL;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
SendAsyncCallback(hIC, hHttpSession, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhs->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_NAME_RESOLVED,
|
||||
&(lpwhs->socketAddress),
|
||||
sizeof(struct sockaddr_in));
|
||||
|
||||
TRACE("<-- %p\n", handle);
|
||||
lend:
|
||||
if( lpwhr )
|
||||
WININET_Release( &lpwhr->hdr );
|
||||
|
||||
TRACE("<-- %p (%p)\n", handle, lpwhr);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -1136,12 +1116,16 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel,
|
|||
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return FALSE;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
bSuccess = HTTP_HttpQueryInfoW( lpwhr, dwInfoLevel,
|
||||
lpBuffer, lpdwBufferLength, lpdwIndex);
|
||||
|
||||
lend:
|
||||
if( lpwhr )
|
||||
WININET_Release( &lpwhr->hdr );
|
||||
|
||||
TRACE("%d <--\n", bSuccess);
|
||||
return bSuccess;
|
||||
}
|
||||
|
@ -1217,6 +1201,7 @@ BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
|||
LPWININETHTTPREQW lpwhr;
|
||||
LPWININETHTTPSESSIONW lpwhs = NULL;
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
BOOL r;
|
||||
|
||||
TRACE("%p, %p (%s), %li, %p, %li)\n", hHttpRequest,
|
||||
lpszHeaders, debugstr_w(lpszHeaders), dwHeaderLength, lpOptional, dwOptionalLength);
|
||||
|
@ -1225,21 +1210,24 @@ BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
|||
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return FALSE;
|
||||
r = FALSE;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
|
||||
if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return FALSE;
|
||||
r = FALSE;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
|
||||
if (NULL == hIC || hIC->hdr.htype != WH_HINIT)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return FALSE;
|
||||
r = FALSE;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
|
||||
|
@ -1248,7 +1236,7 @@ BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
|||
struct WORKREQ_HTTPSENDREQUESTW *req;
|
||||
|
||||
workRequest.asyncall = HTTPSENDREQUESTW;
|
||||
workRequest.handle = hHttpRequest;
|
||||
workRequest.hdr = WININET_AddRef( &lpwhr->hdr );
|
||||
req = &workRequest.u.HttpSendRequestW;
|
||||
if (lpszHeaders)
|
||||
req->lpszHeader = WININET_strdupW(lpszHeaders);
|
||||
|
@ -1263,13 +1251,17 @@ BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
|||
* This is from windows.
|
||||
*/
|
||||
SetLastError(ERROR_IO_PENDING);
|
||||
return 0;
|
||||
r = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return HTTP_HttpSendRequestW(hHttpRequest, lpszHeaders,
|
||||
r = HTTP_HttpSendRequestW(lpwhr, lpszHeaders,
|
||||
dwHeaderLength, lpOptional, dwOptionalLength);
|
||||
}
|
||||
lend:
|
||||
if( lpwhr )
|
||||
WININET_Release( &lpwhr->hdr );
|
||||
return r;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -1309,7 +1301,6 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST
|
|||
LPWININETHTTPSESSIONW lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
|
||||
LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
|
||||
WCHAR path[2048];
|
||||
HINTERNET handle;
|
||||
|
||||
if(lpszUrl[0]=='/')
|
||||
{
|
||||
|
@ -1374,7 +1365,7 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST
|
|||
HeapFree(GetProcessHeap(), 0, lpwhr->lpszHostName);
|
||||
lpwhr->lpszHostName=WININET_strdupW(hostName);
|
||||
|
||||
SendAsyncCallback(hIC, lpwhs, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhs->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_RESOLVING_NAME,
|
||||
lpwhs->lpszServerName,
|
||||
strlenW(lpwhs->lpszServerName)+1);
|
||||
|
@ -1386,7 +1377,7 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
SendAsyncCallback(hIC, lpwhs, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhs->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_NAME_RESOLVED,
|
||||
&(lpwhs->socketAddress),
|
||||
sizeof(struct sockaddr_in));
|
||||
|
@ -1414,8 +1405,7 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQW lpwhr, LPCWSTR lpszUrl, LPCWST
|
|||
}
|
||||
}
|
||||
|
||||
handle = WININET_FindHandle( &lpwhr->hdr );
|
||||
return HttpSendRequestW(handle, lpszHeaders, dwHeaderLength, lpOptional, dwOptionalLength);
|
||||
return HTTP_HttpSendRequestW(lpwhr, lpszHeaders, dwHeaderLength, lpOptional, dwOptionalLength);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -1451,7 +1441,7 @@ static LPWSTR HTTP_build_req( LPCWSTR *list, int len )
|
|||
* FALSE on failure
|
||||
*
|
||||
*/
|
||||
BOOL WINAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
||||
BOOL WINAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
|
||||
DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength)
|
||||
{
|
||||
INT cnt;
|
||||
|
@ -1459,21 +1449,14 @@ BOOL WINAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
|||
BOOL bSuccess = FALSE;
|
||||
LPWSTR requestString = NULL;
|
||||
INT responseLen;
|
||||
LPWININETHTTPREQW lpwhr;
|
||||
LPWININETHTTPSESSIONW lpwhs = NULL;
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
BOOL loop_next = FALSE;
|
||||
int CustHeaderIndex;
|
||||
|
||||
TRACE("--> 0x%08lx\n", (ULONG)hHttpRequest);
|
||||
TRACE("--> %p\n", lpwhr);
|
||||
|
||||
/* Verify our tree of internet handles */
|
||||
lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hHttpRequest );
|
||||
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return FALSE;
|
||||
}
|
||||
assert(lpwhr->hdr.htype == WH_HHTTPREQ);
|
||||
|
||||
lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
|
||||
if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION)
|
||||
|
@ -1613,7 +1596,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
|||
if (!HTTP_OpenConnection(lpwhr))
|
||||
goto lend;
|
||||
|
||||
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_SENDING_REQUEST, NULL, 0);
|
||||
|
||||
/* send the request as ASCII, tack on the optional data */
|
||||
|
@ -1630,11 +1613,11 @@ BOOL WINAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
|||
NETCON_send(&lpwhr->netConnection, ascii_req, len, 0, &cnt);
|
||||
HeapFree( GetProcessHeap(), 0, ascii_req );
|
||||
|
||||
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_REQUEST_SENT,
|
||||
&len,sizeof(DWORD));
|
||||
|
||||
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_RECEIVING_RESPONSE, NULL, 0);
|
||||
|
||||
if (cnt < 0)
|
||||
|
@ -1644,7 +1627,7 @@ BOOL WINAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
|||
if (responseLen)
|
||||
bSuccess = TRUE;
|
||||
|
||||
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_RESPONSE_RECEIVED, &responseLen,
|
||||
sizeof(DWORD));
|
||||
|
||||
|
@ -1744,7 +1727,7 @@ lend:
|
|||
dwIndex=0;
|
||||
if(HTTP_HttpQueryInfoW(lpwhr,HTTP_QUERY_LOCATION,szNewLocation,&dwBufferSize,&dwIndex))
|
||||
{
|
||||
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_REDIRECT, szNewLocation,
|
||||
dwBufferSize);
|
||||
return HTTP_HandleRedirect(lpwhr, szNewLocation, lpszHeaders,
|
||||
|
@ -1760,7 +1743,7 @@ lend:
|
|||
iar.dwResult = (DWORD)bSuccess;
|
||||
iar.dwError = bSuccess ? ERROR_SUCCESS : INTERNET_GetLastError();
|
||||
|
||||
SendAsyncCallback(hIC, hHttpRequest, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
|
||||
sizeof(INTERNET_ASYNC_RESULT));
|
||||
}
|
||||
|
@ -1780,21 +1763,18 @@ lend:
|
|||
* NULL on failure
|
||||
*
|
||||
*/
|
||||
HINTERNET HTTP_Connect(HINTERNET hInternet, LPCWSTR lpszServerName,
|
||||
HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
|
||||
INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
|
||||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
|
||||
DWORD dwInternalFlags)
|
||||
{
|
||||
BOOL bSuccess = FALSE;
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
LPWININETHTTPSESSIONW lpwhs = NULL;
|
||||
HINTERNET handle = NULL;
|
||||
|
||||
TRACE("-->\n");
|
||||
|
||||
hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
|
||||
if( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
|
||||
goto lerror;
|
||||
assert( hIC->hdr.htype == WH_HINIT );
|
||||
|
||||
hIC->hdr.dwContext = dwContext;
|
||||
|
||||
|
@ -1805,14 +1785,6 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCWSTR lpszServerName,
|
|||
goto lerror;
|
||||
}
|
||||
|
||||
handle = WININET_AllocHandle( &lpwhs->hdr );
|
||||
if (NULL == handle)
|
||||
{
|
||||
ERR("Failed to alloc handle\n");
|
||||
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
||||
goto lerror;
|
||||
}
|
||||
|
||||
/*
|
||||
* According to my tests. The name is not resolved until a request is sent
|
||||
*/
|
||||
|
@ -1821,10 +1793,21 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCWSTR lpszServerName,
|
|||
nServerPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
|
||||
lpwhs->hdr.htype = WH_HHTTPSESSION;
|
||||
lpwhs->hdr.lpwhparent = &hIC->hdr;
|
||||
lpwhs->hdr.lpwhparent = WININET_AddRef( &hIC->hdr );
|
||||
lpwhs->hdr.dwFlags = dwFlags;
|
||||
lpwhs->hdr.dwContext = dwContext;
|
||||
lpwhs->hdr.dwInternalFlags = dwInternalFlags;
|
||||
lpwhs->hdr.dwRefCount = 1;
|
||||
lpwhs->hdr.destroy = HTTP_CloseHTTPSessionHandle;
|
||||
|
||||
handle = WININET_AllocHandle( &lpwhs->hdr );
|
||||
if (NULL == handle)
|
||||
{
|
||||
ERR("Failed to alloc handle\n");
|
||||
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
||||
goto lerror;
|
||||
}
|
||||
|
||||
if(hIC->lpszProxy && hIC->dwAccessType == INTERNET_OPEN_TYPE_PROXY) {
|
||||
if(strchrW(hIC->lpszProxy, ' '))
|
||||
FIXME("Several proxies not implemented.\n");
|
||||
|
@ -1845,7 +1828,7 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCWSTR lpszServerName,
|
|||
iar.dwResult = (DWORD)handle;
|
||||
iar.dwError = ERROR_SUCCESS;
|
||||
|
||||
SendAsyncCallback(hIC, hInternet, dwContext,
|
||||
SendAsyncCallback(hIC, &hIC->hdr, dwContext,
|
||||
INTERNET_STATUS_HANDLE_CREATED, &iar,
|
||||
sizeof(INTERNET_ASYNC_RESULT));
|
||||
}
|
||||
|
@ -1853,19 +1836,15 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCWSTR lpszServerName,
|
|||
bSuccess = TRUE;
|
||||
|
||||
lerror:
|
||||
if (!bSuccess && lpwhs)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, lpwhs);
|
||||
WININET_FreeHandle( handle );
|
||||
lpwhs = NULL;
|
||||
}
|
||||
if( lpwhs )
|
||||
WININET_Release( &lpwhs->hdr );
|
||||
|
||||
/*
|
||||
* a INTERNET_STATUS_REQUEST_COMPLETE is NOT sent here as per my tests on
|
||||
* windows
|
||||
*/
|
||||
|
||||
TRACE("%p --> %p\n", hInternet, handle);
|
||||
TRACE("%p --> %p (%p)\n", hIC, handle, lpwhs);
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
@ -1898,7 +1877,7 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr)
|
|||
lpwhs = (LPWININETHTTPSESSIONW)lpwhr->hdr.lpwhparent;
|
||||
|
||||
hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
|
||||
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_CONNECTING_TO_SERVER,
|
||||
&(lpwhs->socketAddress),
|
||||
sizeof(struct sockaddr_in));
|
||||
|
@ -1917,7 +1896,7 @@ BOOL HTTP_OpenConnection(LPWININETHTTPREQW lpwhr)
|
|||
goto lend;
|
||||
}
|
||||
|
||||
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_CONNECTED_TO_SERVER,
|
||||
&(lpwhs->socketAddress),
|
||||
sizeof(struct sockaddr_in));
|
||||
|
@ -2100,7 +2079,7 @@ lend:
|
|||
* TRUE on success
|
||||
* FALSE on error
|
||||
*/
|
||||
INT stripSpaces(LPCWSTR lpszSrc, LPWSTR lpszStart, INT *len)
|
||||
static INT stripSpaces(LPCWSTR lpszSrc, LPWSTR lpszStart, INT *len)
|
||||
{
|
||||
LPCWSTR lpsztmp;
|
||||
INT srclen;
|
||||
|
@ -2411,19 +2390,15 @@ BOOL HTTP_ProcessHeader(LPWININETHTTPREQW lpwhr, LPCWSTR field, LPCWSTR value, D
|
|||
*/
|
||||
VOID HTTP_CloseConnection(LPWININETHTTPREQW lpwhr)
|
||||
{
|
||||
|
||||
|
||||
LPWININETHTTPSESSIONW lpwhs = NULL;
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
HINTERNET handle;
|
||||
|
||||
TRACE("%p\n",lpwhr);
|
||||
|
||||
handle = WININET_FindHandle( &lpwhr->hdr );
|
||||
lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
|
||||
hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
|
||||
|
||||
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
|
||||
|
||||
if (NETCON_connected(&lpwhr->netConnection))
|
||||
|
@ -2431,7 +2406,7 @@ VOID HTTP_CloseConnection(LPWININETHTTPREQW lpwhr)
|
|||
NETCON_close(&lpwhr->netConnection);
|
||||
}
|
||||
|
||||
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwhr->hdr, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_CONNECTION_CLOSED, 0, 0);
|
||||
}
|
||||
|
||||
|
@ -2442,26 +2417,16 @@ VOID HTTP_CloseConnection(LPWININETHTTPREQW lpwhr)
|
|||
* Deallocate request handle
|
||||
*
|
||||
*/
|
||||
void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQW lpwhr)
|
||||
static void HTTP_CloseHTTPRequestHandle(LPWININETHANDLEHEADER hdr)
|
||||
{
|
||||
int i;
|
||||
LPWININETHTTPSESSIONW lpwhs = NULL;
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
HINTERNET handle;
|
||||
LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) hdr;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
if (NETCON_connected(&lpwhr->netConnection))
|
||||
HTTP_CloseConnection(lpwhr);
|
||||
|
||||
handle = WININET_FindHandle( &lpwhr->hdr );
|
||||
lpwhs = (LPWININETHTTPSESSIONW) lpwhr->hdr.lpwhparent;
|
||||
hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
|
||||
|
||||
SendAsyncCallback(hIC, handle, lpwhr->hdr.dwContext,
|
||||
INTERNET_STATUS_HANDLE_CLOSING, lpwhr,
|
||||
sizeof(HINTERNET));
|
||||
|
||||
if (lpwhr->lpszPath)
|
||||
HeapFree(GetProcessHeap(), 0, lpwhr->lpszPath);
|
||||
if (lpwhr->lpszVerb)
|
||||
|
@ -2489,15 +2454,6 @@ void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQW lpwhr)
|
|||
|
||||
HeapFree(GetProcessHeap(), 0, lpwhr->pCustHeaders);
|
||||
HeapFree(GetProcessHeap(), 0, lpwhr);
|
||||
|
||||
/* If this handle was opened with InternetOpenUrl, we need to close the parent to prevent
|
||||
a memory leek
|
||||
*/
|
||||
if(lpwhs->hdr.dwInternalFlags & INET_OPENURL)
|
||||
{
|
||||
handle = WININET_FindHandle( &lpwhs->hdr );
|
||||
InternetCloseHandle(handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2507,24 +2463,12 @@ void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQW lpwhr)
|
|||
* Deallocate session handle
|
||||
*
|
||||
*/
|
||||
void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONW lpwhs)
|
||||
void HTTP_CloseHTTPSessionHandle(LPWININETHANDLEHEADER hdr)
|
||||
{
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
HINTERNET handle;
|
||||
LPWININETHTTPSESSIONW lpwhs = (LPWININETHTTPSESSIONW) hdr;
|
||||
|
||||
TRACE("%p\n", lpwhs);
|
||||
|
||||
hIC = (LPWININETAPPINFOW) lpwhs->hdr.lpwhparent;
|
||||
|
||||
/* Don't send a handle closing callback if this handle was created with InternetOpenUrl */
|
||||
if(!(lpwhs->hdr.dwInternalFlags & INET_OPENURL))
|
||||
{
|
||||
handle = WININET_FindHandle( &lpwhs->hdr );
|
||||
SendAsyncCallback(hIC, handle, lpwhs->hdr.dwContext,
|
||||
INTERNET_STATUS_HANDLE_CLOSING, lpwhs,
|
||||
sizeof(HINTERNET));
|
||||
}
|
||||
|
||||
if (lpwhs->lpszServerName)
|
||||
HeapFree(GetProcessHeap(), 0, lpwhs->lpszServerName);
|
||||
if (lpwhs->lpszUserName)
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#include <assert.h>
|
||||
|
||||
#include "ntstatus.h"
|
||||
#include "windef.h"
|
||||
|
@ -81,10 +82,11 @@ typedef struct
|
|||
CHAR response[MAX_REPLY_LEN];
|
||||
} WITHREADERROR, *LPWITHREADERROR;
|
||||
|
||||
BOOL WINAPI INTERNET_FindNextFileW(HINTERNET hFind, LPVOID lpvFindData);
|
||||
HINTERNET WINAPI INTERNET_InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
||||
LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext);
|
||||
VOID INTERNET_ExecuteWork();
|
||||
static VOID INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr);
|
||||
BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData);
|
||||
HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
|
||||
LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext);
|
||||
static VOID INTERNET_ExecuteWork();
|
||||
|
||||
DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
|
||||
DWORD dwNumThreads;
|
||||
|
@ -145,7 +147,7 @@ HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info )
|
|||
handle = WININET_dwNextHandle;
|
||||
if( WININET_Handles[handle] )
|
||||
ERR("handle isn't free but should be\n");
|
||||
WININET_Handles[handle] = info;
|
||||
WININET_Handles[handle] = WININET_AddRef( info );
|
||||
|
||||
while( WININET_Handles[WININET_dwNextHandle] &&
|
||||
(WININET_dwNextHandle < WININET_dwMaxHandles ) )
|
||||
|
@ -166,6 +168,7 @@ HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info )
|
|||
{
|
||||
if( info == WININET_Handles[i] )
|
||||
{
|
||||
WININET_AddRef( info );
|
||||
handle = i+1;
|
||||
break;
|
||||
}
|
||||
|
@ -175,6 +178,13 @@ HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info )
|
|||
return (HINTERNET) handle;
|
||||
}
|
||||
|
||||
LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info )
|
||||
{
|
||||
info->dwRefCount++;
|
||||
TRACE("%p -> refcount = %ld\n", info, info->dwRefCount );
|
||||
return info;
|
||||
}
|
||||
|
||||
LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
|
||||
{
|
||||
LPWININETHANDLEHEADER info = NULL;
|
||||
|
@ -183,7 +193,7 @@ LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
|
|||
EnterCriticalSection( &WININET_cs );
|
||||
|
||||
if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) )
|
||||
info = WININET_Handles[handle-1];
|
||||
info = WININET_AddRef( WININET_Handles[handle-1] );
|
||||
|
||||
LeaveCriticalSection( &WININET_cs );
|
||||
|
||||
|
@ -192,18 +202,33 @@ LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
|
|||
return info;
|
||||
}
|
||||
|
||||
BOOL WININET_Release( LPWININETHANDLEHEADER info )
|
||||
{
|
||||
info->dwRefCount--;
|
||||
TRACE( "object %p refcount = %ld\n", info, info->dwRefCount );
|
||||
if( !info->dwRefCount )
|
||||
{
|
||||
TRACE( "destroying object %p\n", info);
|
||||
info->destroy( info );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL WININET_FreeHandle( HINTERNET hinternet )
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
UINT handle = (UINT) hinternet;
|
||||
LPWININETHANDLEHEADER info = NULL;
|
||||
|
||||
EnterCriticalSection( &WININET_cs );
|
||||
|
||||
if( (handle > 1) && ( handle < WININET_dwMaxHandles ) )
|
||||
if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) )
|
||||
{
|
||||
handle--;
|
||||
if( WININET_Handles[handle] )
|
||||
{
|
||||
info = WININET_Handles[handle];
|
||||
TRACE( "destroying handle %d for object %p\n", handle+1, info);
|
||||
WININET_Handles[handle] = NULL;
|
||||
ret = TRUE;
|
||||
if( WININET_dwNextHandle > handle )
|
||||
|
@ -213,6 +238,9 @@ BOOL WININET_FreeHandle( HINTERNET hinternet )
|
|||
|
||||
LeaveCriticalSection( &WININET_cs );
|
||||
|
||||
if( info )
|
||||
WININET_Release( info );
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -461,6 +489,8 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
|
|||
lpwai->hdr.htype = WH_HINIT;
|
||||
lpwai->hdr.lpwhparent = NULL;
|
||||
lpwai->hdr.dwFlags = dwFlags;
|
||||
lpwai->hdr.dwRefCount = 1;
|
||||
lpwai->hdr.destroy = INTERNET_CloseHandle;
|
||||
lpwai->dwAccessType = dwAccessType;
|
||||
lpwai->lpszProxyUsername = NULL;
|
||||
lpwai->lpszProxyPassword = NULL;
|
||||
|
@ -498,8 +528,11 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
|
|||
lstrcpyW( lpwai->lpszProxyBypass, lpszProxyBypass );
|
||||
}
|
||||
|
||||
lend:
|
||||
TRACE("returning %p\n", (HINTERNET)lpwai);
|
||||
lend:
|
||||
if( lpwai )
|
||||
WININET_Release( &lpwai->hdr );
|
||||
|
||||
TRACE("returning %p\n", lpwai);
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
@ -652,6 +685,7 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
|
|||
LPCWSTR lpszUserName, LPCWSTR lpszPassword,
|
||||
DWORD dwService, DWORD dwFlags, DWORD dwContext)
|
||||
{
|
||||
LPWININETAPPINFOW hIC;
|
||||
HINTERNET rc = (HINTERNET) NULL;
|
||||
|
||||
TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet, debugstr_w(lpszServerName),
|
||||
|
@ -660,16 +694,19 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
|
|||
|
||||
/* Clear any error information */
|
||||
INTERNET_SetLastError(0);
|
||||
hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
|
||||
if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
|
||||
goto lend;
|
||||
|
||||
switch (dwService)
|
||||
{
|
||||
case INTERNET_SERVICE_FTP:
|
||||
rc = FTP_Connect(hInternet, lpszServerName, nServerPort,
|
||||
rc = FTP_Connect(hIC, lpszServerName, nServerPort,
|
||||
lpszUserName, lpszPassword, dwFlags, dwContext, 0);
|
||||
break;
|
||||
|
||||
case INTERNET_SERVICE_HTTP:
|
||||
rc = HTTP_Connect(hInternet, lpszServerName, nServerPort,
|
||||
rc = HTTP_Connect(hIC, lpszServerName, nServerPort,
|
||||
lpszUserName, lpszPassword, dwFlags, dwContext, 0);
|
||||
break;
|
||||
|
||||
|
@ -677,6 +714,9 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
lend:
|
||||
if( hIC )
|
||||
WININET_Release( &hIC->hdr );
|
||||
|
||||
TRACE("returning %p\n", rc);
|
||||
return rc;
|
||||
|
@ -769,15 +809,15 @@ BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
|
|||
{
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
LPWININETFINDNEXTW lpwh;
|
||||
BOOL bSuccess = FALSE;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
lpwh = (LPWININETFINDNEXTW) WININET_GetObject( hFind );
|
||||
|
||||
if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return FALSE;
|
||||
goto lend;
|
||||
}
|
||||
|
||||
hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
|
||||
|
@ -787,16 +827,20 @@ BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
|
|||
struct WORKREQ_INTERNETFINDNEXTW *req;
|
||||
|
||||
workRequest.asyncall = INTERNETFINDNEXTW;
|
||||
workRequest.handle = hFind;
|
||||
workRequest.hdr = WININET_AddRef( &lpwh->hdr );
|
||||
req = &workRequest.u.InternetFindNextW;
|
||||
req->lpFindFileData = lpvFindData;
|
||||
|
||||
return INTERNET_AsyncCall(&workRequest);
|
||||
bSuccess = INTERNET_AsyncCall(&workRequest);
|
||||
}
|
||||
else
|
||||
{
|
||||
return INTERNET_FindNextFileW(hFind, lpvFindData);
|
||||
bSuccess = INTERNET_FindNextFileW(lpwh, lpvFindData);
|
||||
}
|
||||
lend:
|
||||
if( lpwh )
|
||||
WININET_Release( &lpwh->hdr );
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -809,21 +853,15 @@ BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
|
|||
* FALSE on failure
|
||||
*
|
||||
*/
|
||||
BOOL WINAPI INTERNET_FindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
|
||||
BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData)
|
||||
{
|
||||
BOOL bSuccess = TRUE;
|
||||
LPWININETAPPINFOW hIC = NULL;
|
||||
LPWIN32_FIND_DATAW lpFindFileData;
|
||||
LPWININETFINDNEXTW lpwh;
|
||||
|
||||
TRACE("\n");
|
||||
|
||||
lpwh = (LPWININETFINDNEXTW) WININET_GetObject( hFind );
|
||||
if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
|
||||
{
|
||||
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
||||
return FALSE;
|
||||
}
|
||||
assert (lpwh->hdr.htype == WH_HFINDNEXT);
|
||||
|
||||
/* Clear any error information */
|
||||
INTERNET_SetLastError(0);
|
||||
|
@ -863,7 +901,7 @@ lend:
|
|||
iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
|
||||
INTERNET_GetLastError();
|
||||
|
||||
SendAsyncCallback(hIC, hFind, lpwh->hdr.dwContext,
|
||||
SendAsyncCallback(hIC, &lpwh->hdr, lpwh->hdr.dwContext,
|
||||
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
|
||||
sizeof(INTERNET_ASYNC_RESULT));
|
||||
}
|
||||
|
@ -881,13 +919,11 @@ lend:
|
|||
* Void
|
||||
*
|
||||
*/
|
||||
VOID INTERNET_CloseHandle(LPWININETAPPINFOW lpwai)
|
||||
static VOID INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr)
|
||||
{
|
||||
TRACE("%p\n",lpwai);
|
||||
LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW) hdr;
|
||||
|
||||
SendAsyncCallback(lpwai, lpwai, lpwai->hdr.dwContext,
|
||||
INTERNET_STATUS_HANDLE_CLOSING, lpwai,
|
||||
sizeof(HINTERNET));
|
||||
TRACE("%p\n",lpwai);
|
||||
|
||||
if (lpwai->lpszAgent)
|
||||
HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
|
||||
|
@ -920,9 +956,9 @@ VOID INTERNET_CloseHandle(LPWININETAPPINFOW lpwai)
|
|||
*/
|
||||
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
|
||||
{
|
||||
BOOL retval;
|
||||
LPWININETHANDLEHEADER lpwh;
|
||||
|
||||
LPWININETHANDLEHEADER lpwh, parent;
|
||||
LPWININETAPPINFOW hIC;
|
||||
|
||||
TRACE("%p\n",hInternet);
|
||||
|
||||
lpwh = WININET_GetObject( hInternet );
|
||||
|
@ -932,46 +968,21 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/* Clear any error information */
|
||||
INTERNET_SetLastError(0);
|
||||
retval = FALSE;
|
||||
parent = lpwh;
|
||||
while( parent && (parent->htype != WH_HINIT ) )
|
||||
parent = parent->lpwhparent;
|
||||
|
||||
switch (lpwh->htype)
|
||||
{
|
||||
case WH_HINIT:
|
||||
INTERNET_CloseHandle((LPWININETAPPINFOW) lpwh);
|
||||
retval = TRUE;
|
||||
break;
|
||||
hIC = (LPWININETAPPINFOW) parent;
|
||||
SendAsyncCallback(hIC, lpwh, lpwh->dwContext,
|
||||
INTERNET_STATUS_HANDLE_CLOSING, hInternet,
|
||||
sizeof(HINTERNET));
|
||||
|
||||
case WH_HHTTPSESSION:
|
||||
HTTP_CloseHTTPSessionHandle((LPWININETHTTPSESSIONW) lpwh);
|
||||
retval = TRUE;
|
||||
break;
|
||||
if( lpwh->lpwhparent )
|
||||
WININET_Release( lpwh->lpwhparent );
|
||||
WININET_FreeHandle( hInternet );
|
||||
WININET_Release( lpwh );
|
||||
|
||||
case WH_HHTTPREQ:
|
||||
HTTP_CloseHTTPRequestHandle((LPWININETHTTPREQW) lpwh);
|
||||
retval = TRUE;
|
||||
break;
|
||||
|
||||
case WH_HFTPSESSION:
|
||||
retval = FTP_CloseSessionHandle((LPWININETFTPSESSIONW) lpwh);
|
||||
break;
|
||||
|
||||
case WH_HFINDNEXT:
|
||||
retval = FTP_CloseFindNextHandle((LPWININETFINDNEXTW) lpwh);
|
||||
break;
|
||||
|
||||
case WH_HFILE:
|
||||
retval = FTP_CloseFileTransferHandle((LPWININETFILE) lpwh);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if( retval )
|
||||
WININET_FreeHandle( hInternet );
|
||||
|
||||
return retval;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1480,21 +1491,22 @@ BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
|
|||
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
|
||||
HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
|
||||
{
|
||||
INTERNET_STATUS_CALLBACK retVal;
|
||||
INTERNET_STATUS_CALLBACK retVal = INTERNET_INVALID_STATUS_CALLBACK;
|
||||
LPWININETAPPINFOW lpwai;
|
||||
|
||||
TRACE("0x%08lx\n", (ULONG)hInternet);
|
||||
|
||||
lpwai = (LPWININETAPPINFOW)WININET_GetObject(hInternet);
|
||||
if (!lpwai)
|
||||
return NULL;
|
||||
return retVal;
|
||||
|
||||
if (lpwai->hdr.htype != WH_HINIT)
|
||||
return INTERNET_INVALID_STATUS_CALLBACK;
|
||||
|
||||
lpwai->hdr.dwInternalFlags &= ~INET_CALLBACKW;
|
||||
retVal = lpwai->lpfnStatusCB;
|
||||
lpwai->lpfnStatusCB = lpfnIntCB;
|
||||
if (lpwai->hdr.htype == WH_HINIT)
|
||||
{
|
||||
lpwai->hdr.dwInternalFlags &= ~INET_CALLBACKW;
|
||||
retVal = lpwai->lpfnStatusCB;
|
||||
lpwai->lpfnStatusCB = lpfnIntCB;
|
||||
}
|
||||
WININET_Release( &lpwai->hdr );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
@ -1513,21 +1525,23 @@ INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
|
|||
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(
|
||||
HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
|
||||
{
|
||||
INTERNET_STATUS_CALLBACK retVal;
|
||||
INTERNET_STATUS_CALLBACK retVal = INTERNET_INVALID_STATUS_CALLBACK;
|
||||
LPWININETAPPINFOW lpwai;
|
||||
|
||||
TRACE("0x%08lx\n", (ULONG)hInternet);
|
||||
|
||||
lpwai = (LPWININETAPPINFOW)WININET_GetObject(hInternet);
|
||||
if (!lpwai)
|
||||
return NULL;
|
||||
return retVal;
|
||||
|
||||
if (lpwai->hdr.htype != WH_HINIT)
|
||||
return INTERNET_INVALID_STATUS_CALLBACK;
|
||||
if (lpwai->hdr.htype == WH_HINIT)
|
||||
{
|
||||
lpwai->hdr.dwInternalFlags |= INET_CALLBACKW;
|
||||
retVal = lpwai->lpfnStatusCB;
|
||||
lpwai->lpfnStatusCB = lpfnIntCB;
|
||||
}
|
||||
|
||||
lpwai->hdr.dwInternalFlags |= INET_CALLBACKW;
|
||||
retVal = lpwai->lpfnStatusCB;
|
||||
lpwai->lpfnStatusCB = lpfnIntCB;
|
||||
WININET_Release( &lpwai->hdr );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
@ -1586,6 +1600,7 @@ BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
|
|||
retval = (res >= 0);
|
||||
*lpdwNumOfBytesWritten = retval ? res : 0;
|
||||
}
|
||||
WININET_Release( lpwh );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -1608,7 +1623,7 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
|
|||
int nSocket = -1;
|
||||
LPWININETHANDLEHEADER lpwh;
|
||||
|
||||
TRACE("\n");
|
||||
TRACE("%p %p %ld %p\n", hFile, lpBuffer, dwNumOfBytesToRead, dwNumOfBytesRead);
|
||||
|
||||
lpwh = (LPWININETHANDLEHEADER) WININET_GetObject( hFile );
|
||||
if (NULL == lpwh)
|
||||
|
@ -1642,6 +1657,7 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
WININET_Release( lpwh );
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -1778,6 +1794,7 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d
|
|||
FIXME("Stub! %ld \n",dwOption);
|
||||
break;
|
||||
}
|
||||
WININET_Release( lpwhh );
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
@ -1829,6 +1846,7 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
|
|||
LPVOID lpBuffer, DWORD dwBufferLength)
|
||||
{
|
||||
LPWININETHANDLEHEADER lpwhh;
|
||||
BOOL ret = TRUE;
|
||||
|
||||
TRACE("0x%08lx\n", dwOption);
|
||||
|
||||
|
@ -1886,8 +1904,10 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
|
|||
default:
|
||||
FIXME("Option %ld STUB\n",dwOption);
|
||||
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
ret = FALSE;
|
||||
break;
|
||||
}
|
||||
WININET_Release( lpwhh );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -2097,7 +2117,7 @@ BOOL WINAPI InternetCheckConnectionW(LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRes
|
|||
* RETURNS
|
||||
* handle of connection or NULL on failure
|
||||
*/
|
||||
HINTERNET WINAPI INTERNET_InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
||||
HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
|
||||
LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
|
||||
{
|
||||
URL_COMPONENTSW urlComponents;
|
||||
|
@ -2105,7 +2125,7 @@ HINTERNET WINAPI INTERNET_InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
|||
WCHAR password[1024], path[2048], extra[1024];
|
||||
HINTERNET client = NULL, client1 = NULL;
|
||||
|
||||
TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
|
||||
TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hIC, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
|
||||
dwHeadersLength, dwFlags, dwContext);
|
||||
|
||||
urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
|
||||
|
@ -2127,7 +2147,7 @@ HINTERNET WINAPI INTERNET_InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
|||
case INTERNET_SCHEME_FTP:
|
||||
if(urlComponents.nPort == 0)
|
||||
urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
|
||||
client = FTP_Connect(hInternet, hostName, urlComponents.nPort,
|
||||
client = FTP_Connect(hIC, hostName, urlComponents.nPort,
|
||||
userName, password, dwFlags, dwContext, INET_OPENURL);
|
||||
if(client == NULL)
|
||||
break;
|
||||
|
@ -2148,7 +2168,8 @@ HINTERNET WINAPI INTERNET_InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
|||
else
|
||||
urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
}
|
||||
client = HTTP_Connect(hInternet, hostName, urlComponents.nPort,
|
||||
/* FIXME: should use pointers, not handles, as handles are not thread-safe */
|
||||
client = HTTP_Connect(hIC, hostName, urlComponents.nPort,
|
||||
userName, password, dwFlags, dwContext, INET_OPENURL);
|
||||
if(client == NULL)
|
||||
break;
|
||||
|
@ -2158,7 +2179,7 @@ HINTERNET WINAPI INTERNET_InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
|||
break;
|
||||
}
|
||||
HttpAddRequestHeadersW(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
|
||||
if (!HTTP_HttpSendRequestW(client1, NULL, 0, NULL, 0)) {
|
||||
if (!HttpSendRequestW(client1, NULL, 0, NULL, 0)) {
|
||||
InternetCloseHandle(client1);
|
||||
client1 = NULL;
|
||||
break;
|
||||
|
@ -2204,7 +2225,7 @@ HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
|||
struct WORKREQ_INTERNETOPENURLW *req;
|
||||
|
||||
workRequest.asyncall = INTERNETOPENURLW;
|
||||
workRequest.handle = hInternet;
|
||||
workRequest.hdr = WININET_AddRef( &hIC->hdr );
|
||||
req = &workRequest.u.InternetOpenUrlW;
|
||||
if (lpszUrl)
|
||||
req->lpszUrl = WININET_strdupW(lpszUrl);
|
||||
|
@ -2224,10 +2245,12 @@ HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
|||
*/
|
||||
SetLastError(ERROR_IO_PENDING);
|
||||
} else {
|
||||
ret = INTERNET_InternetOpenUrlW(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
|
||||
ret = INTERNET_InternetOpenUrlW(hIC, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
|
||||
}
|
||||
|
||||
lend:
|
||||
if( hIC )
|
||||
WININET_Release( &hIC->hdr );
|
||||
TRACE(" %p <--\n", ret);
|
||||
|
||||
return ret;
|
||||
|
@ -2476,7 +2499,7 @@ lerror:
|
|||
* RETURNS
|
||||
*
|
||||
*/
|
||||
VOID INTERNET_ExecuteWork()
|
||||
static VOID INTERNET_ExecuteWork()
|
||||
{
|
||||
WORKREQUEST workRequest;
|
||||
|
||||
|
@ -2485,45 +2508,16 @@ VOID INTERNET_ExecuteWork()
|
|||
if (!INTERNET_GetWorkRequest(&workRequest))
|
||||
return;
|
||||
|
||||
if (TRACE_ON(wininet)) {
|
||||
static const wininet_flag_info work_request_types[] = {
|
||||
#define FE(x) { x, #x }
|
||||
FE(FTPPUTFILEW),
|
||||
FE(FTPSETCURRENTDIRECTORYW),
|
||||
FE(FTPCREATEDIRECTORYW),
|
||||
FE(FTPFINDFIRSTFILEW),
|
||||
FE(FTPGETCURRENTDIRECTORYW),
|
||||
FE(FTPOPENFILEW),
|
||||
FE(FTPGETFILEW),
|
||||
FE(FTPDELETEFILEW),
|
||||
FE(FTPREMOVEDIRECTORYW),
|
||||
FE(FTPRENAMEFILEW),
|
||||
FE(INTERNETFINDNEXTW),
|
||||
FE(HTTPSENDREQUESTW),
|
||||
FE(HTTPOPENREQUESTW),
|
||||
FE(SENDCALLBACK),
|
||||
FE(INTERNETOPENURLW)
|
||||
#undef FE
|
||||
};
|
||||
int i;
|
||||
const char *val = "Unknown";
|
||||
|
||||
for (i = 0; i < (sizeof(work_request_types) / sizeof(work_request_types[0])); i++) {
|
||||
if (work_request_types[i].val == workRequest.asyncall) {
|
||||
val = work_request_types[i].name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
TRACE("Got work %d (%s)\n", workRequest.asyncall, val);
|
||||
}
|
||||
switch (workRequest.asyncall)
|
||||
{
|
||||
case FTPPUTFILEW:
|
||||
{
|
||||
struct WORKREQ_FTPPUTFILEW *req = &workRequest.u.FtpPutFileW;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
FTP_FtpPutFileW(workRequest.handle, req->lpszLocalFile,
|
||||
TRACE("FTPPUTFILEW %p\n", lpwfs);
|
||||
|
||||
FTP_FtpPutFileW(lpwfs, req->lpszLocalFile,
|
||||
req->lpszNewRemoteFile, req->dwFlags, req->dwContext);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszLocalFile);
|
||||
|
@ -2534,9 +2528,12 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPSETCURRENTDIRECTORYW:
|
||||
{
|
||||
struct WORKREQ_FTPSETCURRENTDIRECTORYW *req;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
TRACE("FTPSETCURRENTDIRECTORYW %p\n", lpwfs);
|
||||
|
||||
req = &workRequest.u.FtpSetCurrentDirectoryW;
|
||||
FTP_FtpSetCurrentDirectoryW(workRequest.handle, req->lpszDirectory);
|
||||
FTP_FtpSetCurrentDirectoryW(lpwfs, req->lpszDirectory);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
|
||||
}
|
||||
break;
|
||||
|
@ -2544,9 +2541,12 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPCREATEDIRECTORYW:
|
||||
{
|
||||
struct WORKREQ_FTPCREATEDIRECTORYW *req;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
TRACE("FTPCREATEDIRECTORYW %p\n", lpwfs);
|
||||
|
||||
req = &workRequest.u.FtpCreateDirectoryW;
|
||||
FTP_FtpCreateDirectoryW(workRequest.handle, req->lpszDirectory);
|
||||
FTP_FtpCreateDirectoryW(lpwfs, req->lpszDirectory);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
|
||||
}
|
||||
break;
|
||||
|
@ -2554,9 +2554,12 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPFINDFIRSTFILEW:
|
||||
{
|
||||
struct WORKREQ_FTPFINDFIRSTFILEW *req;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
TRACE("FTPFINDFIRSTFILEW %p\n", lpwfs);
|
||||
|
||||
req = &workRequest.u.FtpFindFirstFileW;
|
||||
FTP_FtpFindFirstFileW(workRequest.handle, req->lpszSearchFile,
|
||||
FTP_FtpFindFirstFileW(lpwfs, req->lpszSearchFile,
|
||||
req->lpFindFileData, req->dwFlags, req->dwContext);
|
||||
if (req->lpszSearchFile != NULL)
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszSearchFile);
|
||||
|
@ -2566,9 +2569,12 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPGETCURRENTDIRECTORYW:
|
||||
{
|
||||
struct WORKREQ_FTPGETCURRENTDIRECTORYW *req;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
TRACE("FTPGETCURRENTDIRECTORYW %p\n", lpwfs);
|
||||
|
||||
req = &workRequest.u.FtpGetCurrentDirectoryW;
|
||||
FTP_FtpGetCurrentDirectoryW(workRequest.handle,
|
||||
FTP_FtpGetCurrentDirectoryW(lpwfs,
|
||||
req->lpszDirectory, req->lpdwDirectory);
|
||||
}
|
||||
break;
|
||||
|
@ -2576,8 +2582,11 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPOPENFILEW:
|
||||
{
|
||||
struct WORKREQ_FTPOPENFILEW *req = &workRequest.u.FtpOpenFileW;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
FTP_FtpOpenFileW(workRequest.handle, req->lpszFilename,
|
||||
TRACE("FTPOPENFILEW %p\n", lpwfs);
|
||||
|
||||
FTP_FtpOpenFileW(lpwfs, req->lpszFilename,
|
||||
req->dwAccess, req->dwFlags, req->dwContext);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszFilename);
|
||||
}
|
||||
|
@ -2586,8 +2595,11 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPGETFILEW:
|
||||
{
|
||||
struct WORKREQ_FTPGETFILEW *req = &workRequest.u.FtpGetFileW;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
FTP_FtpGetFileW(workRequest.handle, req->lpszRemoteFile,
|
||||
TRACE("FTPGETFILEW %p\n", lpwfs);
|
||||
|
||||
FTP_FtpGetFileW(lpwfs, req->lpszRemoteFile,
|
||||
req->lpszNewFile, req->fFailIfExists,
|
||||
req->dwLocalFlagsAttribute, req->dwFlags, req->dwContext);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszRemoteFile);
|
||||
|
@ -2598,8 +2610,11 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPDELETEFILEW:
|
||||
{
|
||||
struct WORKREQ_FTPDELETEFILEW *req = &workRequest.u.FtpDeleteFileW;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
FTP_FtpDeleteFileW(workRequest.handle, req->lpszFilename);
|
||||
TRACE("FTPDELETEFILEW %p\n", lpwfs);
|
||||
|
||||
FTP_FtpDeleteFileW(lpwfs, req->lpszFilename);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszFilename);
|
||||
}
|
||||
break;
|
||||
|
@ -2607,9 +2622,12 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPREMOVEDIRECTORYW:
|
||||
{
|
||||
struct WORKREQ_FTPREMOVEDIRECTORYW *req;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
TRACE("FTPREMOVEDIRECTORYW %p\n", lpwfs);
|
||||
|
||||
req = &workRequest.u.FtpRemoveDirectoryW;
|
||||
FTP_FtpRemoveDirectoryW(workRequest.handle, req->lpszDirectory);
|
||||
FTP_FtpRemoveDirectoryW(lpwfs, req->lpszDirectory);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
|
||||
}
|
||||
break;
|
||||
|
@ -2617,8 +2635,11 @@ VOID INTERNET_ExecuteWork()
|
|||
case FTPRENAMEFILEW:
|
||||
{
|
||||
struct WORKREQ_FTPRENAMEFILEW *req = &workRequest.u.FtpRenameFileW;
|
||||
LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
|
||||
|
||||
FTP_FtpRenameFileW(workRequest.handle, req->lpszSrcFile, req->lpszDestFile);
|
||||
TRACE("FTPRENAMEFILEW %p\n", lpwfs);
|
||||
|
||||
FTP_FtpRenameFileW(lpwfs, req->lpszSrcFile, req->lpszDestFile);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszSrcFile);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszDestFile);
|
||||
}
|
||||
|
@ -2627,17 +2648,23 @@ VOID INTERNET_ExecuteWork()
|
|||
case INTERNETFINDNEXTW:
|
||||
{
|
||||
struct WORKREQ_INTERNETFINDNEXTW *req;
|
||||
LPWININETFINDNEXTW lpwh = (LPWININETFINDNEXTW) workRequest.hdr;
|
||||
|
||||
TRACE("INTERNETFINDNEXTW %p\n", lpwh);
|
||||
|
||||
req = &workRequest.u.InternetFindNextW;
|
||||
INTERNET_FindNextFileW(workRequest.handle, req->lpFindFileData);
|
||||
INTERNET_FindNextFileW(lpwh, req->lpFindFileData);
|
||||
}
|
||||
break;
|
||||
|
||||
case HTTPSENDREQUESTW:
|
||||
{
|
||||
struct WORKREQ_HTTPSENDREQUESTW *req = &workRequest.u.HttpSendRequestW;
|
||||
LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) workRequest.hdr;
|
||||
|
||||
HTTP_HttpSendRequestW(workRequest.handle, req->lpszHeader,
|
||||
TRACE("HTTPSENDREQUESTW %p\n", lpwhr);
|
||||
|
||||
HTTP_HttpSendRequestW(lpwhr, req->lpszHeader,
|
||||
req->dwHeaderLength, req->lpOptional, req->dwOptionalLength);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszHeader);
|
||||
|
@ -2647,8 +2674,11 @@ VOID INTERNET_ExecuteWork()
|
|||
case HTTPOPENREQUESTW:
|
||||
{
|
||||
struct WORKREQ_HTTPOPENREQUESTW *req = &workRequest.u.HttpOpenRequestW;
|
||||
LPWININETHTTPSESSIONW lpwhs = (LPWININETHTTPSESSIONW) workRequest.hdr;
|
||||
|
||||
HTTP_HttpOpenRequestW(workRequest.handle, req->lpszVerb,
|
||||
TRACE("HTTPOPENREQUESTW %p\n", lpwhs);
|
||||
|
||||
HTTP_HttpOpenRequestW(lpwhs, req->lpszVerb,
|
||||
req->lpszObjectName, req->lpszVersion, req->lpszReferrer,
|
||||
req->lpszAcceptTypes, req->dwFlags, req->dwContext);
|
||||
|
||||
|
@ -2662,8 +2692,11 @@ VOID INTERNET_ExecuteWork()
|
|||
case SENDCALLBACK:
|
||||
{
|
||||
struct WORKREQ_SENDCALLBACK *req = &workRequest.u.SendCallback;
|
||||
LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) workRequest.hdr;
|
||||
|
||||
SendAsyncCallbackInt(workRequest.handle, req->hHttpSession,
|
||||
TRACE("SENDCALLBACK %p\n", hIC);
|
||||
|
||||
SendAsyncCallbackInt(hIC, req->hdr,
|
||||
req->dwContext, req->dwInternetStatus, req->lpvStatusInfo,
|
||||
req->dwStatusInfoLength);
|
||||
}
|
||||
|
@ -2672,14 +2705,18 @@ VOID INTERNET_ExecuteWork()
|
|||
case INTERNETOPENURLW:
|
||||
{
|
||||
struct WORKREQ_INTERNETOPENURLW *req = &workRequest.u.InternetOpenUrlW;
|
||||
LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) workRequest.hdr;
|
||||
|
||||
INTERNET_InternetOpenUrlW(workRequest.handle, req->lpszUrl,
|
||||
TRACE("INTERNETOPENURLW %p\n", hIC);
|
||||
|
||||
INTERNET_InternetOpenUrlW(hIC, req->lpszUrl,
|
||||
req->lpszHeaders, req->dwHeadersLength, req->dwFlags, req->dwContext);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszUrl);
|
||||
HeapFree(GetProcessHeap(), 0, req->lpszHeaders);
|
||||
}
|
||||
break;
|
||||
}
|
||||
WININET_Release( workRequest.hdr );
|
||||
}
|
||||
|
||||
|
||||
|
@ -2772,7 +2809,6 @@ BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
|
|||
INT retval = -1;
|
||||
char buffer[4048];
|
||||
|
||||
|
||||
lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hFile );
|
||||
if (NULL == lpwhr)
|
||||
{
|
||||
|
@ -2799,6 +2835,7 @@ BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
|
|||
FIXME("unsupported file type\n");
|
||||
break;
|
||||
}
|
||||
WININET_Release( &lpwhr->hdr );
|
||||
|
||||
TRACE("<-- %i\n",retval);
|
||||
return (retval+1);
|
||||
|
|
|
@ -120,15 +120,22 @@ typedef enum
|
|||
#define INET_OPENURL 0x0001
|
||||
#define INET_CALLBACKW 0x0002
|
||||
|
||||
typedef struct _WININETHANDLEHEADER
|
||||
struct _WININETHANDLEHEADER;
|
||||
typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
|
||||
|
||||
typedef void (*WININET_object_destructor)( LPWININETHANDLEHEADER );
|
||||
|
||||
struct _WININETHANDLEHEADER
|
||||
{
|
||||
WH_TYPE htype;
|
||||
DWORD dwFlags;
|
||||
DWORD dwContext;
|
||||
DWORD dwError;
|
||||
DWORD dwInternalFlags;
|
||||
DWORD dwRefCount;
|
||||
WININET_object_destructor destroy;
|
||||
struct _WININETHANDLEHEADER *lpwhparent;
|
||||
} WININETHANDLEHEADER, *LPWININETHANDLEHEADER;
|
||||
};
|
||||
|
||||
|
||||
typedef struct
|
||||
|
@ -333,7 +340,7 @@ struct WORKREQ_HTTPSENDREQUESTW
|
|||
|
||||
struct WORKREQ_SENDCALLBACK
|
||||
{
|
||||
HINTERNET hHttpSession;
|
||||
WININETHANDLEHEADER *hdr;
|
||||
DWORD dwContext;
|
||||
DWORD dwInternetStatus;
|
||||
LPVOID lpvStatusInfo;
|
||||
|
@ -353,7 +360,7 @@ struct WORKREQ_INTERNETOPENURLW
|
|||
typedef struct WORKREQ
|
||||
{
|
||||
ASYNC_FUNC asyncall;
|
||||
HINTERNET handle;
|
||||
WININETHANDLEHEADER *hdr;
|
||||
|
||||
union {
|
||||
struct WORKREQ_FTPPUTFILEW FtpPutFileW;
|
||||
|
@ -380,17 +387,19 @@ typedef struct WORKREQ
|
|||
|
||||
HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
|
||||
LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
|
||||
LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info );
|
||||
BOOL WININET_Release( LPWININETHANDLEHEADER info );
|
||||
BOOL WININET_FreeHandle( HINTERNET hinternet );
|
||||
HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
|
||||
|
||||
time_t ConvertTimeString(LPCWSTR asctime);
|
||||
|
||||
HINTERNET FTP_Connect(HINTERNET hInterent, LPCWSTR lpszServerName,
|
||||
HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
|
||||
INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
|
||||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
|
||||
DWORD dwInternalFlags);
|
||||
|
||||
HINTERNET HTTP_Connect(HINTERNET hInterent, LPCWSTR lpszServerName,
|
||||
HINTERNET HTTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
|
||||
INTERNET_PORT nServerPort, LPCWSTR lpszUserName,
|
||||
LPCWSTR lpszPassword, DWORD dwFlags, DWORD dwContext,
|
||||
DWORD dwInternalFlags);
|
||||
|
@ -404,41 +413,36 @@ BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest);
|
|||
LPSTR INTERNET_GetResponseBuffer();
|
||||
LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen);
|
||||
|
||||
BOOL FTP_CloseSessionHandle(LPWININETFTPSESSIONW lpwfs);
|
||||
BOOL FTP_CloseFindNextHandle(LPWININETFINDNEXTW lpwfn);
|
||||
BOOL FTP_CloseFileTransferHandle(LPWININETFILE lpwfn);
|
||||
BOOLAPI FTP_FtpPutFileW(HINTERNET hConnect, LPCWSTR lpszLocalFile,
|
||||
BOOLAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
|
||||
LPCWSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext);
|
||||
BOOLAPI FTP_FtpSetCurrentDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory);
|
||||
BOOLAPI FTP_FtpCreateDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory);
|
||||
INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(HINTERNET hConnect,
|
||||
BOOLAPI FTP_FtpSetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
|
||||
BOOLAPI FTP_FtpCreateDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
|
||||
INTERNETAPI HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
|
||||
LPCWSTR lpszSearchFile, LPWIN32_FIND_DATAW lpFindFileData, DWORD dwFlags, DWORD dwContext);
|
||||
BOOLAPI FTP_FtpGetCurrentDirectoryW(HINTERNET hFtpSession, LPWSTR lpszCurrentDirectory,
|
||||
BOOLAPI FTP_FtpGetCurrentDirectoryW(LPWININETFTPSESSIONW lpwfs, LPWSTR lpszCurrentDirectory,
|
||||
LPDWORD lpdwCurrentDirectory);
|
||||
BOOL FTP_ConvertFileProp(LPFILEPROPERTIESW lpafp, LPWIN32_FIND_DATAW lpFindFileData);
|
||||
BOOL FTP_FtpRenameFileW(HINTERNET hFtpSession, LPCWSTR lpszSrc, LPCWSTR lpszDest);
|
||||
BOOL FTP_FtpRemoveDirectoryW(HINTERNET hFtpSession, LPCWSTR lpszDirectory);
|
||||
BOOL FTP_FtpDeleteFileW(HINTERNET hFtpSession, LPCWSTR lpszFileName);
|
||||
HINTERNET FTP_FtpOpenFileW(HINTERNET hFtpSession, LPCWSTR lpszFileName,
|
||||
BOOL FTP_FtpRenameFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszSrc, LPCWSTR lpszDest);
|
||||
BOOL FTP_FtpRemoveDirectoryW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszDirectory);
|
||||
BOOL FTP_FtpDeleteFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName);
|
||||
HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszFileName,
|
||||
DWORD fdwAccess, DWORD dwFlags, DWORD dwContext);
|
||||
BOOLAPI FTP_FtpGetFileW(HINTERNET hInternet, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
|
||||
BOOLAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, LPCWSTR lpszNewFile,
|
||||
BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
|
||||
DWORD dwContext);
|
||||
|
||||
BOOLAPI HTTP_HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders,
|
||||
BOOLAPI HTTP_HttpSendRequestW(LPWININETHTTPREQW lpwhr, LPCWSTR lpszHeaders,
|
||||
DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength);
|
||||
INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
|
||||
INTERNETAPI HINTERNET WINAPI HTTP_HttpOpenRequestW(LPWININETHTTPSESSIONW lpwhs,
|
||||
LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion,
|
||||
LPCWSTR lpszReferrer , LPCWSTR *lpszAcceptTypes,
|
||||
DWORD dwFlags, DWORD dwContext);
|
||||
void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONW lpwhs);
|
||||
void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQW lpwhr);
|
||||
|
||||
VOID SendAsyncCallback(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
|
||||
VOID SendAsyncCallback(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr,
|
||||
DWORD dwContext, DWORD dwInternetStatus, LPVOID
|
||||
lpvStatusInfo , DWORD dwStatusInfoLength);
|
||||
|
||||
VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
|
||||
VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr,
|
||||
DWORD dwContext, DWORD dwInternetStatus, LPVOID
|
||||
lpvStatusInfo , DWORD dwStatusInfoLength);
|
||||
|
||||
|
|
|
@ -215,12 +215,14 @@ static const char *get_callback_name(DWORD dwInternetStatus) {
|
|||
return "Unknown";
|
||||
}
|
||||
|
||||
VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
|
||||
VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr,
|
||||
DWORD dwContext, DWORD dwInternetStatus, LPVOID
|
||||
lpvStatusInfo, DWORD dwStatusInfoLength)
|
||||
{
|
||||
HINTERNET hHttpSession;
|
||||
LPVOID lpvNewInfo = NULL;
|
||||
if (! (hIC->lpfnStatusCB))
|
||||
|
||||
if( !hIC->lpfnStatusCB )
|
||||
return;
|
||||
|
||||
/* the IE5 version of wininet does not
|
||||
|
@ -230,6 +232,10 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
|
|||
|
||||
TRACE("--> Callback %ld (%s)\n",dwInternetStatus, get_callback_name(dwInternetStatus));
|
||||
|
||||
hHttpSession = WININET_FindHandle( hdr );
|
||||
if( !hHttpSession )
|
||||
return;
|
||||
|
||||
lpvNewInfo = lpvStatusInfo;
|
||||
if(!(hIC->hdr.dwInternalFlags & INET_CALLBACKW)) {
|
||||
switch(dwInternetStatus)
|
||||
|
@ -245,11 +251,13 @@ VOID SendAsyncCallbackInt(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
|
|||
HeapFree(GetProcessHeap(), 0, lpvNewInfo);
|
||||
|
||||
TRACE("<-- Callback %ld (%s)\n",dwInternetStatus, get_callback_name(dwInternetStatus));
|
||||
|
||||
WININET_Release( hdr );
|
||||
}
|
||||
|
||||
|
||||
|
||||
VOID SendAsyncCallback(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
|
||||
VOID SendAsyncCallback(LPWININETAPPINFOW hIC, LPWININETHANDLEHEADER hdr,
|
||||
DWORD dwContext, DWORD dwInternetStatus, LPVOID
|
||||
lpvStatusInfo, DWORD dwStatusInfoLength)
|
||||
{
|
||||
|
@ -263,9 +271,9 @@ VOID SendAsyncCallback(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
|
|||
struct WORKREQ_SENDCALLBACK *req;
|
||||
|
||||
workRequest.asyncall = SENDCALLBACK;
|
||||
workRequest.handle = hIC;
|
||||
workRequest.hdr = WININET_AddRef( &hIC->hdr );
|
||||
req = &workRequest.u.SendCallback;
|
||||
req->hHttpSession = hHttpSession;
|
||||
req->hdr = hdr;
|
||||
req->dwContext = dwContext;
|
||||
req->dwInternetStatus = dwInternetStatus;
|
||||
req->lpvStatusInfo = lpvStatusInfo;
|
||||
|
@ -274,6 +282,6 @@ VOID SendAsyncCallback(LPWININETAPPINFOW hIC, HINTERNET hHttpSession,
|
|||
INTERNET_AsyncCall(&workRequest);
|
||||
}
|
||||
else
|
||||
SendAsyncCallbackInt(hIC, hHttpSession, dwContext, dwInternetStatus,
|
||||
SendAsyncCallbackInt(hIC, hdr, dwContext, dwInternetStatus,
|
||||
lpvStatusInfo, dwStatusInfoLength);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue