mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-27 03:43:36 +00:00
[WINHTTP] Winesync to Wine-10.0
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
|
||||
remove_definitions(-D_WIN32_WINNT=0x502)
|
||||
remove_definitions(-D_WIN32_WINNT=0x502 -D_CRT_NON_CONFORMING_SWPRINTFS)
|
||||
add_definitions(-D_WIN32_WINNT=0x600)
|
||||
|
||||
add_definitions(
|
||||
-D_WINE)
|
||||
-D_WINE
|
||||
-D_WINHTTP_INTERNAL_)
|
||||
|
||||
spec2def(winhttp.dll winhttp.spec ADD_IMPORTLIB)
|
||||
|
||||
@@ -26,8 +27,8 @@ add_library(winhttp MODULE
|
||||
${CMAKE_CURRENT_BINARY_DIR}/winhttp.def)
|
||||
|
||||
set_module_type(winhttp win32dll)
|
||||
target_link_libraries(winhttp uuid wine)
|
||||
add_delay_importlibs(winhttp oleaut32 crypt32 secur32)
|
||||
target_link_libraries(winhttp uuid wine oldnames wine_dll_register)
|
||||
add_delay_importlibs(winhttp oleaut32 crypt32 secur32 iphlpapi dhcpcsvc)
|
||||
add_importlibs(winhttp user32 advapi32 ws2_32 jsproxy kernel32_vista msvcrt kernel32 ntdll)
|
||||
add_dependencies(winhttp stdole2)
|
||||
add_pch(winhttp precomp.h SOURCE)
|
||||
|
||||
+53
-54
@@ -16,12 +16,12 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include "winhttp.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
@@ -49,12 +49,12 @@ static struct domain *add_domain( struct session *session, WCHAR *name )
|
||||
{
|
||||
struct domain *domain;
|
||||
|
||||
if (!(domain = heap_alloc_zero( sizeof(struct domain) ))) return NULL;
|
||||
if (!(domain = calloc( 1, sizeof(*domain) ))) return NULL;
|
||||
|
||||
list_init( &domain->entry );
|
||||
list_init( &domain->cookies );
|
||||
|
||||
domain->name = strdupW( name );
|
||||
domain->name = wcsdup( name );
|
||||
list_add_tail( &session->cookie_cache, &domain->entry );
|
||||
|
||||
TRACE("%s\n", debugstr_w(domain->name));
|
||||
@@ -69,7 +69,7 @@ static struct cookie *find_cookie( struct domain *domain, const WCHAR *path, con
|
||||
LIST_FOR_EACH( item, &domain->cookies )
|
||||
{
|
||||
cookie = LIST_ENTRY( item, struct cookie, entry );
|
||||
if (!strcmpW( cookie->path, path ) && !strcmpW( cookie->name, name ))
|
||||
if (!wcscmp( cookie->path, path ) && !wcscmp( cookie->name, name ))
|
||||
{
|
||||
TRACE("found %s=%s\n", debugstr_w(cookie->name), debugstr_w(cookie->value));
|
||||
return cookie;
|
||||
@@ -82,17 +82,17 @@ static BOOL domain_match( const WCHAR *name, struct domain *domain, BOOL partial
|
||||
{
|
||||
TRACE("comparing %s with %s\n", debugstr_w(name), debugstr_w(domain->name));
|
||||
|
||||
if (partial && !strstrW( name, domain->name )) return FALSE;
|
||||
else if (!partial && strcmpW( name, domain->name )) return FALSE;
|
||||
if (partial && !wcsstr( name, domain->name )) return FALSE;
|
||||
else if (!partial && wcscmp( name, domain->name )) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void free_cookie( struct cookie *cookie )
|
||||
{
|
||||
heap_free( cookie->name );
|
||||
heap_free( cookie->value );
|
||||
heap_free( cookie->path );
|
||||
heap_free( cookie );
|
||||
free( cookie->name );
|
||||
free( cookie->value );
|
||||
free( cookie->path );
|
||||
free( cookie );
|
||||
}
|
||||
|
||||
static void delete_cookie( struct cookie *cookie )
|
||||
@@ -113,8 +113,8 @@ static void delete_domain( struct domain *domain )
|
||||
}
|
||||
|
||||
list_remove( &domain->entry );
|
||||
heap_free( domain->name );
|
||||
heap_free( domain );
|
||||
free( domain->name );
|
||||
free( domain );
|
||||
}
|
||||
|
||||
void destroy_cookies( struct session *session )
|
||||
@@ -135,7 +135,7 @@ static BOOL add_cookie( struct session *session, struct cookie *cookie, WCHAR *d
|
||||
struct cookie *old_cookie;
|
||||
struct list *item;
|
||||
|
||||
if (!(cookie->path = strdupW( path ))) return FALSE;
|
||||
if (!(cookie->path = wcsdup( path ))) return FALSE;
|
||||
|
||||
EnterCriticalSection( &session->cs );
|
||||
|
||||
@@ -165,17 +165,17 @@ static struct cookie *parse_cookie( const WCHAR *string )
|
||||
const WCHAR *p;
|
||||
int len;
|
||||
|
||||
if (!(p = strchrW( string, '=' ))) p = string + strlenW( string );
|
||||
if (!(p = wcschr( string, '=' ))) p = string + lstrlenW( string );
|
||||
len = p - string;
|
||||
while (len && string[len - 1] == ' ') len--;
|
||||
if (!len) return NULL;
|
||||
|
||||
if (!(cookie = heap_alloc_zero( sizeof(struct cookie) ))) return NULL;
|
||||
if (!(cookie = calloc( 1, sizeof(*cookie) ))) return NULL;
|
||||
list_init( &cookie->entry );
|
||||
|
||||
if (!(cookie->name = heap_alloc( (len + 1) * sizeof(WCHAR) )))
|
||||
if (!(cookie->name = malloc( (len + 1) * sizeof(WCHAR) )))
|
||||
{
|
||||
heap_free( cookie );
|
||||
free( cookie );
|
||||
return NULL;
|
||||
}
|
||||
memcpy( cookie->name, string, len * sizeof(WCHAR) );
|
||||
@@ -184,10 +184,10 @@ static struct cookie *parse_cookie( const WCHAR *string )
|
||||
if (*p++ == '=')
|
||||
{
|
||||
while (*p == ' ') p++;
|
||||
len = strlenW( p );
|
||||
len = lstrlenW( p );
|
||||
while (len && p[len - 1] == ' ') len--;
|
||||
|
||||
if (!(cookie->value = heap_alloc( (len + 1) * sizeof(WCHAR) )))
|
||||
if (!(cookie->value = malloc( (len + 1) * sizeof(WCHAR) )))
|
||||
{
|
||||
free_cookie( cookie );
|
||||
return NULL;
|
||||
@@ -207,9 +207,9 @@ struct attr
|
||||
static void free_attr( struct attr *attr )
|
||||
{
|
||||
if (!attr) return;
|
||||
heap_free( attr->name );
|
||||
heap_free( attr->value );
|
||||
heap_free( attr );
|
||||
free( attr->name );
|
||||
free( attr->value );
|
||||
free( attr );
|
||||
}
|
||||
|
||||
static struct attr *parse_attr( const WCHAR *str, int *used )
|
||||
@@ -224,10 +224,10 @@ static struct attr *parse_attr( const WCHAR *str, int *used )
|
||||
len = q - p;
|
||||
if (!len) return NULL;
|
||||
|
||||
if (!(attr = heap_alloc( sizeof(struct attr) ))) return NULL;
|
||||
if (!(attr->name = heap_alloc( (len + 1) * sizeof(WCHAR) )))
|
||||
if (!(attr = malloc( sizeof(*attr) ))) return NULL;
|
||||
if (!(attr->name = malloc( (len + 1) * sizeof(WCHAR) )))
|
||||
{
|
||||
heap_free( attr );
|
||||
free( attr );
|
||||
return NULL;
|
||||
}
|
||||
memcpy( attr->name, p, len * sizeof(WCHAR) );
|
||||
@@ -244,7 +244,7 @@ static struct attr *parse_attr( const WCHAR *str, int *used )
|
||||
len = q - p;
|
||||
while (len && p[len - 1] == ' ') len--;
|
||||
|
||||
if (!(attr->value = heap_alloc( (len + 1) * sizeof(WCHAR) )))
|
||||
if (!(attr->value = malloc( (len + 1) * sizeof(WCHAR) )))
|
||||
{
|
||||
free_attr( attr );
|
||||
return NULL;
|
||||
@@ -262,8 +262,6 @@ static struct attr *parse_attr( const WCHAR *str, int *used )
|
||||
|
||||
BOOL set_cookies( struct request *request, const WCHAR *cookies )
|
||||
{
|
||||
static const WCHAR pathW[] = {'p','a','t','h',0};
|
||||
static const WCHAR domainW[] = {'d','o','m','a','i','n',0};
|
||||
BOOL ret = FALSE;
|
||||
WCHAR *buffer, *p;
|
||||
WCHAR *cookie_domain = NULL, *cookie_path = NULL;
|
||||
@@ -272,27 +270,27 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
|
||||
struct cookie *cookie;
|
||||
int len, used;
|
||||
|
||||
len = strlenW( cookies );
|
||||
if (!(buffer = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
|
||||
strcpyW( buffer, cookies );
|
||||
len = lstrlenW( cookies );
|
||||
if (!(buffer = malloc( (len + 1) * sizeof(WCHAR) ))) return FALSE;
|
||||
lstrcpyW( buffer, cookies );
|
||||
|
||||
p = buffer;
|
||||
while (*p && *p != ';') p++;
|
||||
if (*p == ';') *p++ = 0;
|
||||
if (!(cookie = parse_cookie( buffer )))
|
||||
{
|
||||
heap_free( buffer );
|
||||
free( buffer );
|
||||
return FALSE;
|
||||
}
|
||||
len = strlenW( p );
|
||||
len = lstrlenW( p );
|
||||
while (len && (attr = parse_attr( p, &used )))
|
||||
{
|
||||
if (!strcmpiW( attr->name, domainW ))
|
||||
if (!wcsicmp( attr->name, L"domain" ))
|
||||
{
|
||||
domain = attr;
|
||||
cookie_domain = attr->value;
|
||||
}
|
||||
else if (!strcmpiW( attr->name, pathW ))
|
||||
else if (!wcsicmp( attr->name, L"path" ))
|
||||
{
|
||||
path = attr;
|
||||
cookie_path = attr->value;
|
||||
@@ -305,26 +303,27 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
|
||||
len -= used;
|
||||
p += used;
|
||||
}
|
||||
if (!cookie_domain && !(cookie_domain = strdupW( request->connect->servername ))) goto end;
|
||||
if (!cookie_path && !(cookie_path = strdupW( request->path ))) goto end;
|
||||
if (!cookie_domain && !(cookie_domain = wcsdup( request->connect->servername ))) goto end;
|
||||
if (!cookie_path && !(cookie_path = wcsdup( request->path ))) goto end;
|
||||
|
||||
if ((p = strrchrW( cookie_path, '/' )) && p != cookie_path) *p = 0;
|
||||
if ((p = wcsrchr( cookie_path, '/' )) && p != cookie_path) *p = 0;
|
||||
ret = add_cookie( session, cookie, cookie_domain, cookie_path );
|
||||
|
||||
end:
|
||||
if (!ret) free_cookie( cookie );
|
||||
if (domain) free_attr( domain );
|
||||
else heap_free( cookie_domain );
|
||||
else free( cookie_domain );
|
||||
if (path) free_attr( path );
|
||||
else heap_free( cookie_path );
|
||||
heap_free( buffer );
|
||||
else free( cookie_path );
|
||||
free( buffer );
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL add_cookie_headers( struct request *request )
|
||||
DWORD add_cookie_headers( struct request *request )
|
||||
{
|
||||
struct list *domain_cursor;
|
||||
struct session *session = request->connect->session;
|
||||
DWORD ret = ERROR_SUCCESS;
|
||||
|
||||
EnterCriticalSection( &session->cs );
|
||||
|
||||
@@ -342,37 +341,37 @@ BOOL add_cookie_headers( struct request *request )
|
||||
|
||||
TRACE("comparing path %s with %s\n", debugstr_w(request->path), debugstr_w(cookie->path));
|
||||
|
||||
if (strstrW( request->path, cookie->path ) == request->path)
|
||||
if (wcsstr( request->path, cookie->path ) == request->path)
|
||||
{
|
||||
static const WCHAR cookieW[] = {'C','o','o','k','i','e',':',' '};
|
||||
int len, len_cookie = ARRAY_SIZE( cookieW ), len_name = strlenW( cookie->name );
|
||||
int len, len_cookie = ARRAY_SIZE( cookieW ), len_name = lstrlenW( cookie->name );
|
||||
WCHAR *header;
|
||||
|
||||
len = len_cookie + len_name;
|
||||
if (cookie->value) len += strlenW( cookie->value ) + 1;
|
||||
if (!(header = heap_alloc( (len + 1) * sizeof(WCHAR) )))
|
||||
if (cookie->value) len += lstrlenW( cookie->value ) + 1;
|
||||
if (!(header = malloc( (len + 1) * sizeof(WCHAR) )))
|
||||
{
|
||||
LeaveCriticalSection( &session->cs );
|
||||
return FALSE;
|
||||
return ERROR_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
memcpy( header, cookieW, len_cookie * sizeof(WCHAR) );
|
||||
strcpyW( header + len_cookie, cookie->name );
|
||||
lstrcpyW( header + len_cookie, cookie->name );
|
||||
if (cookie->value)
|
||||
{
|
||||
header[len_cookie + len_name] = '=';
|
||||
strcpyW( header + len_cookie + len_name + 1, cookie->value );
|
||||
lstrcpyW( header + len_cookie + len_name + 1, cookie->value );
|
||||
}
|
||||
|
||||
TRACE("%s\n", debugstr_w(header));
|
||||
add_request_headers( request, header, len,
|
||||
WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON );
|
||||
heap_free( header );
|
||||
ret = add_request_headers( request, header, len,
|
||||
WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON );
|
||||
free( header );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LeaveCriticalSection( &session->cs );
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
+14
-17
@@ -18,12 +18,11 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include "winhttp.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
@@ -49,7 +48,7 @@ static ULONG_PTR max_handles;
|
||||
struct object_header *addref_object( struct object_header *hdr )
|
||||
{
|
||||
ULONG refs = InterlockedIncrement( &hdr->refs );
|
||||
TRACE("%p -> refcount = %d\n", hdr, refs);
|
||||
TRACE( "%p -> refcount = %lu\n", hdr, refs );
|
||||
return hdr;
|
||||
}
|
||||
|
||||
@@ -65,22 +64,21 @@ struct object_header *grab_object( HINTERNET hinternet )
|
||||
|
||||
LeaveCriticalSection( &handle_cs );
|
||||
|
||||
TRACE("handle 0x%lx -> %p\n", handle, hdr);
|
||||
TRACE( "handle %Ix -> %p\n", handle, hdr );
|
||||
return hdr;
|
||||
}
|
||||
|
||||
void release_object( struct object_header *hdr )
|
||||
{
|
||||
ULONG refs = InterlockedDecrement( &hdr->refs );
|
||||
TRACE("object %p refcount = %d\n", hdr, refs);
|
||||
TRACE( "object %p refcount = %lu\n", hdr, refs );
|
||||
if (!refs)
|
||||
{
|
||||
if (hdr->type == WINHTTP_HANDLE_TYPE_REQUEST) close_connection( (struct request *)hdr );
|
||||
|
||||
send_callback( hdr, WINHTTP_CALLBACK_STATUS_HANDLE_CLOSING, &hdr->handle, sizeof(HINTERNET) );
|
||||
|
||||
TRACE("destroying object %p\n", hdr);
|
||||
if (hdr->type != WINHTTP_HANDLE_TYPE_SESSION) list_remove( &hdr->entry );
|
||||
TRACE( "destroying object %p\n", hdr );
|
||||
hdr->vtbl->destroy( hdr );
|
||||
}
|
||||
}
|
||||
@@ -90,21 +88,23 @@ HINTERNET alloc_handle( struct object_header *hdr )
|
||||
struct object_header **p;
|
||||
ULONG_PTR handle, num;
|
||||
|
||||
list_init( &hdr->children );
|
||||
hdr->handle = NULL;
|
||||
|
||||
EnterCriticalSection( &handle_cs );
|
||||
if (!max_handles)
|
||||
{
|
||||
num = HANDLE_CHUNK_SIZE;
|
||||
if (!(p = heap_alloc_zero( sizeof(ULONG_PTR) * num ))) goto end;
|
||||
if (!(p = calloc( 1, sizeof(*p) * num ))) goto end;
|
||||
handles = p;
|
||||
max_handles = num;
|
||||
}
|
||||
if (max_handles == next_handle)
|
||||
{
|
||||
size_t new_size, old_size = max_handles * sizeof(*handles);
|
||||
num = max_handles * 2;
|
||||
if (!(p = heap_realloc_zero( handles, sizeof(ULONG_PTR) * num ))) goto end;
|
||||
new_size = num * sizeof(*handles);
|
||||
if (!(p = realloc( handles, new_size ))) goto end;
|
||||
memset( (char *)p + old_size, 0, new_size - old_size );
|
||||
handles = p;
|
||||
max_handles = num;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ BOOL free_handle( HINTERNET hinternet )
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
ULONG_PTR handle = (ULONG_PTR)hinternet;
|
||||
struct object_header *hdr = NULL, *child, *next;
|
||||
struct object_header *hdr = NULL;
|
||||
|
||||
EnterCriticalSection( &handle_cs );
|
||||
|
||||
@@ -134,7 +134,7 @@ BOOL free_handle( HINTERNET hinternet )
|
||||
if (handles[handle])
|
||||
{
|
||||
hdr = handles[handle];
|
||||
TRACE("destroying handle 0x%lx for object %p\n", handle + 1, hdr);
|
||||
TRACE( "destroying handle %Ix for object %p\n", handle + 1, hdr );
|
||||
handles[handle] = NULL;
|
||||
ret = TRUE;
|
||||
}
|
||||
@@ -144,11 +144,8 @@ BOOL free_handle( HINTERNET hinternet )
|
||||
|
||||
if (hdr)
|
||||
{
|
||||
LIST_FOR_EACH_ENTRY_SAFE( child, next, &hdr->children, struct object_header, entry )
|
||||
{
|
||||
TRACE("freeing child handle %p for parent handle 0x%lx\n", child->handle, handle + 1);
|
||||
free_handle( child->handle );
|
||||
}
|
||||
if (hdr->vtbl->handle_closing)
|
||||
hdr->vtbl->handle_closing( hdr );
|
||||
release_object( hdr );
|
||||
}
|
||||
|
||||
|
||||
@@ -191,3 +191,10 @@ inet_ntop6(const u_char *src, char *dst, size_t size)
|
||||
}
|
||||
#endif
|
||||
|
||||
/******************************************************************
|
||||
* DllCanUnloadNow (winhttp.@)
|
||||
*/
|
||||
HRESULT WINAPI DllCanUnloadNow(void)
|
||||
{
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#define COBJMACROS
|
||||
#include "config.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#define COBJMACROS
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include "objbase.h"
|
||||
#include "rpcproxy.h"
|
||||
#include "httprequest.h"
|
||||
@@ -156,27 +155,3 @@ HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
||||
if (!cf) return CLASS_E_CLASSNOTAVAILABLE;
|
||||
return IClassFactory_QueryInterface( cf, riid, ppv );
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* DllCanUnloadNow (winhttp.@)
|
||||
*/
|
||||
HRESULT WINAPI DllCanUnloadNow(void)
|
||||
{
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* DllRegisterServer (winhttp.@)
|
||||
*/
|
||||
HRESULT WINAPI DllRegisterServer(void)
|
||||
{
|
||||
return __wine_register_resources( winhttp_instance );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* DllUnregisterServer (winhttp.@)
|
||||
*/
|
||||
HRESULT WINAPI DllUnregisterServer(void)
|
||||
{
|
||||
return __wine_unregister_resources( winhttp_instance );
|
||||
}
|
||||
|
||||
+301
-209
@@ -17,33 +17,57 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#define NONAMELESSUNION
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include "winhttp.h"
|
||||
#include "schannel.h"
|
||||
#include "winternl.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/library.h"
|
||||
#include "winhttp_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
|
||||
|
||||
static int sock_send(int fd, const void *msg, size_t len, int flags)
|
||||
static int sock_send(int fd, const void *msg, size_t len, WSAOVERLAPPED *ovr)
|
||||
{
|
||||
int ret;
|
||||
do
|
||||
WSABUF wsabuf;
|
||||
DWORD size;
|
||||
int err;
|
||||
|
||||
wsabuf.len = len;
|
||||
wsabuf.buf = (void *)msg;
|
||||
|
||||
if (!WSASend( (SOCKET)fd, &wsabuf, 1, &size, 0, ovr, NULL ))
|
||||
{
|
||||
if ((ret = send(fd, msg, len, flags)) == -1) WARN("send error %u\n", WSAGetLastError());
|
||||
assert( size == len );
|
||||
return size;
|
||||
}
|
||||
while(ret == -1 && WSAGetLastError() == WSAEINTR);
|
||||
return ret;
|
||||
err = WSAGetLastError();
|
||||
if (!(ovr && err == WSA_IO_PENDING)) WARN( "send error %d\n", err );
|
||||
return -1;
|
||||
}
|
||||
|
||||
BOOL netconn_wait_overlapped_result( struct netconn *conn, WSAOVERLAPPED *ovr, DWORD *len )
|
||||
{
|
||||
OVERLAPPED *completion_ovr;
|
||||
ULONG_PTR key;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (!GetQueuedCompletionStatus( conn->port, len, &key, &completion_ovr, INFINITE ))
|
||||
{
|
||||
WARN( "GetQueuedCompletionStatus failed, err %lu.\n", GetLastError() );
|
||||
return FALSE;
|
||||
}
|
||||
if (completion_ovr == (OVERLAPPED *)ovr && (key == conn->socket || conn->socket == -1))
|
||||
break;
|
||||
ERR( "Unexpected completion key %Ix, completion ovr %p, ovr %p.\n", key, completion_ovr, ovr );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int sock_recv(int fd, void *msg, size_t len, int flags)
|
||||
@@ -51,7 +75,7 @@ static int sock_recv(int fd, void *msg, size_t len, int flags)
|
||||
int ret;
|
||||
do
|
||||
{
|
||||
if ((ret = recv(fd, msg, len, flags)) == -1) WARN("recv error %u\n", WSAGetLastError());
|
||||
if ((ret = recv(fd, msg, len, flags)) == -1) WARN( "recv error %d\n", WSAGetLastError() );
|
||||
}
|
||||
while(ret == -1 && WSAGetLastError() == WSAEINTR);
|
||||
return ret;
|
||||
@@ -87,8 +111,10 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD secu
|
||||
if (!(security_flags & SECURITY_FLAG_IGNORE_CERT_DATE_INVALID))
|
||||
err = ERROR_WINHTTP_SECURE_CERT_DATE_INVALID;
|
||||
}
|
||||
else if (chain->TrustStatus.dwErrorStatus &
|
||||
CERT_TRUST_IS_UNTRUSTED_ROOT)
|
||||
else if ((chain->TrustStatus.dwErrorStatus &
|
||||
CERT_TRUST_IS_UNTRUSTED_ROOT) ||
|
||||
(chain->TrustStatus.dwErrorStatus &
|
||||
CERT_TRUST_IS_PARTIAL_CHAIN))
|
||||
{
|
||||
if (!(security_flags & SECURITY_FLAG_IGNORE_UNKNOWN_CA))
|
||||
err = ERROR_WINHTTP_SECURE_INVALID_CA;
|
||||
@@ -122,7 +148,7 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD secu
|
||||
*/
|
||||
memcpy(&chainCopy, chain, sizeof(chainCopy));
|
||||
chainCopy.TrustStatus.dwErrorStatus = 0;
|
||||
sslExtraPolicyPara.u.cbSize = sizeof(sslExtraPolicyPara);
|
||||
sslExtraPolicyPara.cbSize = sizeof(sslExtraPolicyPara);
|
||||
sslExtraPolicyPara.dwAuthType = AUTHTYPE_SERVER;
|
||||
sslExtraPolicyPara.pwszServerName = server;
|
||||
sslExtraPolicyPara.fdwChecks = security_flags;
|
||||
@@ -147,7 +173,7 @@ static DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD secu
|
||||
}
|
||||
else
|
||||
err = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
|
||||
TRACE("returning %08x\n", err);
|
||||
TRACE( "returning %#lx\n", err );
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -183,26 +209,30 @@ static void set_blocking( struct netconn *conn, BOOL blocking )
|
||||
ioctlsocket( conn->socket, FIONBIO, &state );
|
||||
}
|
||||
|
||||
struct netconn *netconn_create( struct hostdata *host, const struct sockaddr_storage *sockaddr, int timeout )
|
||||
DWORD netconn_create( struct hostdata *host, const struct sockaddr_storage *sockaddr, int timeout,
|
||||
struct netconn **ret_conn )
|
||||
{
|
||||
struct netconn *conn;
|
||||
unsigned int addr_len;
|
||||
BOOL ret = FALSE;
|
||||
DWORD ret;
|
||||
|
||||
#ifndef __REACTOS__
|
||||
winsock_init();
|
||||
#endif
|
||||
|
||||
conn = heap_alloc_zero(sizeof(*conn));
|
||||
if (!conn) return NULL;
|
||||
if (!(conn = calloc( 1, sizeof(*conn) ))) return ERROR_OUTOFMEMORY;
|
||||
conn->refs = 1;
|
||||
conn->host = host;
|
||||
conn->sockaddr = *sockaddr;
|
||||
if ((conn->socket = socket( sockaddr->ss_family, SOCK_STREAM, 0 )) == -1)
|
||||
if ((conn->socket = WSASocketW( sockaddr->ss_family, SOCK_STREAM, 0, NULL, 0, WSA_FLAG_OVERLAPPED )) == -1)
|
||||
{
|
||||
WARN("unable to create socket (%u)\n", WSAGetLastError());
|
||||
heap_free(conn);
|
||||
return NULL;
|
||||
ret = WSAGetLastError();
|
||||
WARN( "unable to create socket (%lu)\n", ret );
|
||||
free( conn );
|
||||
return ret;
|
||||
}
|
||||
if (!SetFileCompletionNotificationModes( (HANDLE)(UINT_PTR)conn->socket, FILE_SKIP_COMPLETION_PORT_ON_SUCCESS ))
|
||||
ERR( "SetFileCompletionNotificationModes failed.\n" );
|
||||
|
||||
switch (conn->sockaddr.ss_family)
|
||||
{
|
||||
@@ -213,56 +243,77 @@ struct netconn *netconn_create( struct hostdata *host, const struct sockaddr_sto
|
||||
addr_len = sizeof(struct sockaddr_in6);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
ERR( "unhandled family %u\n", conn->sockaddr.ss_family );
|
||||
free( conn );
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (timeout > 0) set_blocking( conn, FALSE );
|
||||
|
||||
if (!connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len )) ret = TRUE;
|
||||
if (!connect( conn->socket, (const struct sockaddr *)&conn->sockaddr, addr_len )) ret = ERROR_SUCCESS;
|
||||
else
|
||||
{
|
||||
DWORD err = WSAGetLastError();
|
||||
if (err == WSAEWOULDBLOCK || err == WSAEINPROGRESS)
|
||||
ret = WSAGetLastError();
|
||||
if (ret == WSAEWOULDBLOCK || ret == WSAEINPROGRESS)
|
||||
{
|
||||
FD_SET set;
|
||||
TIMEVAL timeval = { 0, timeout * 1000 };
|
||||
TIMEVAL timeval = { timeout / 1000, (timeout % 1000) * 1000 };
|
||||
FD_SET set_read, set_error;
|
||||
int res;
|
||||
|
||||
FD_ZERO( &set );
|
||||
FD_SET( conn->socket, &set );
|
||||
if ((res = select( conn->socket + 1, NULL, &set, NULL, &timeval )) > 0) ret = TRUE;
|
||||
else if (!res) SetLastError( ERROR_WINHTTP_TIMEOUT );
|
||||
FD_ZERO( &set_read );
|
||||
FD_SET( conn->socket, &set_read );
|
||||
FD_ZERO( &set_error );
|
||||
FD_SET( conn->socket, &set_error );
|
||||
if ((res = select( conn->socket + 1, NULL, &set_read, &set_error, &timeval )) > 0)
|
||||
{
|
||||
if (FD_ISSET(conn->socket, &set_read)) ret = ERROR_SUCCESS;
|
||||
else assert( FD_ISSET(conn->socket, &set_error) );
|
||||
}
|
||||
else if (!res) ret = ERROR_WINHTTP_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout > 0) set_blocking( conn, TRUE );
|
||||
|
||||
if (!ret)
|
||||
if (ret)
|
||||
{
|
||||
WARN("unable to connect to host (%u)\n", GetLastError());
|
||||
WARN( "unable to connect to host (%lu)\n", ret );
|
||||
closesocket( conn->socket );
|
||||
heap_free( conn );
|
||||
return NULL;
|
||||
free( conn );
|
||||
return ret == ERROR_WINHTTP_TIMEOUT ? ERROR_WINHTTP_TIMEOUT : ERROR_WINHTTP_CANNOT_CONNECT;
|
||||
}
|
||||
return conn;
|
||||
|
||||
*ret_conn = conn;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
void netconn_close( struct netconn *conn )
|
||||
void netconn_addref( struct netconn *conn )
|
||||
{
|
||||
InterlockedIncrement( &conn->refs );
|
||||
}
|
||||
|
||||
void netconn_release( struct netconn *conn )
|
||||
{
|
||||
if (InterlockedDecrement( &conn->refs )) return;
|
||||
TRACE( "Closing connection %p.\n", conn );
|
||||
if (conn->secure)
|
||||
{
|
||||
heap_free( conn->peek_msg_mem );
|
||||
heap_free(conn->ssl_buf);
|
||||
heap_free(conn->extra_buf);
|
||||
free( conn->peek_msg_mem );
|
||||
free(conn->ssl_read_buf);
|
||||
free(conn->ssl_write_buf);
|
||||
free(conn->extra_buf);
|
||||
DeleteSecurityContext(&conn->ssl_ctx);
|
||||
}
|
||||
closesocket( conn->socket );
|
||||
if (conn->socket != -1)
|
||||
closesocket( conn->socket );
|
||||
release_host( conn->host );
|
||||
heap_free(conn);
|
||||
if (conn->port)
|
||||
CloseHandle( conn->port );
|
||||
free(conn);
|
||||
}
|
||||
|
||||
BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle,
|
||||
BOOL check_revocation)
|
||||
DWORD netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD security_flags, CredHandle *cred_handle,
|
||||
BOOL check_revocation )
|
||||
{
|
||||
SecBuffer out_buf = {0, SECBUFFER_TOKEN, NULL}, in_bufs[2] = {{0, SECBUFFER_TOKEN}, {0, SECBUFFER_EMPTY}};
|
||||
SecBufferDesc out_desc = {SECBUFFER_VERSION, 1, &out_buf}, in_desc = {SECBUFFER_VERSION, 2, in_bufs};
|
||||
@@ -278,10 +329,9 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
|
||||
const DWORD isc_req_flags = ISC_REQ_ALLOCATE_MEMORY|ISC_REQ_USE_SESSION_KEY|ISC_REQ_CONFIDENTIALITY
|
||||
|ISC_REQ_SEQUENCE_DETECT|ISC_REQ_REPLAY_DETECT|ISC_REQ_MANUAL_CRED_VALIDATION;
|
||||
|
||||
read_buf = heap_alloc(read_buf_size);
|
||||
if(!read_buf)
|
||||
return FALSE;
|
||||
if (!(read_buf = malloc( read_buf_size ))) return ERROR_OUTOFMEMORY;
|
||||
|
||||
memset( &ctx, 0, sizeof(ctx) );
|
||||
status = InitializeSecurityContextW(cred_handle, NULL, hostname, isc_req_flags, 0, 0, NULL, 0,
|
||||
&ctx, &out_desc, &attrs, NULL);
|
||||
|
||||
@@ -291,9 +341,9 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
|
||||
if(out_buf.cbBuffer) {
|
||||
assert(status == SEC_I_CONTINUE_NEEDED);
|
||||
|
||||
TRACE("sending %u bytes\n", out_buf.cbBuffer);
|
||||
TRACE( "sending %lu bytes\n", out_buf.cbBuffer );
|
||||
|
||||
size = sock_send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, 0);
|
||||
size = sock_send(conn->socket, out_buf.pvBuffer, out_buf.cbBuffer, NULL);
|
||||
if(size != out_buf.cbBuffer) {
|
||||
ERR("send failed\n");
|
||||
res = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
|
||||
@@ -310,19 +360,17 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
|
||||
|
||||
memmove(read_buf, (BYTE*)in_bufs[0].pvBuffer+in_bufs[0].cbBuffer-in_bufs[1].cbBuffer, in_bufs[1].cbBuffer);
|
||||
in_bufs[0].cbBuffer = in_bufs[1].cbBuffer;
|
||||
|
||||
in_bufs[1].BufferType = SECBUFFER_EMPTY;
|
||||
in_bufs[1].cbBuffer = 0;
|
||||
in_bufs[1].pvBuffer = NULL;
|
||||
}
|
||||
|
||||
assert(in_bufs[0].BufferType == SECBUFFER_TOKEN);
|
||||
assert(in_bufs[1].BufferType == SECBUFFER_EMPTY);
|
||||
in_bufs[1].BufferType = SECBUFFER_EMPTY;
|
||||
in_bufs[1].cbBuffer = 0;
|
||||
in_bufs[1].pvBuffer = NULL;
|
||||
|
||||
if(in_bufs[0].cbBuffer + 1024 > read_buf_size) {
|
||||
BYTE *new_read_buf;
|
||||
|
||||
new_read_buf = heap_realloc(read_buf, read_buf_size + 1024);
|
||||
new_read_buf = realloc(read_buf, read_buf_size + 1024);
|
||||
if(!new_read_buf) {
|
||||
status = E_OUTOFMEMORY;
|
||||
break;
|
||||
@@ -338,13 +386,13 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE("recv %lu bytes\n", size);
|
||||
TRACE( "recv %Iu bytes\n", size );
|
||||
|
||||
in_bufs[0].cbBuffer += size;
|
||||
in_bufs[0].pvBuffer = read_buf;
|
||||
status = InitializeSecurityContextW(cred_handle, &ctx, hostname, isc_req_flags, 0, 0, &in_desc,
|
||||
0, NULL, &out_desc, &attrs, NULL);
|
||||
TRACE("InitializeSecurityContext ret %08x\n", status);
|
||||
TRACE( "InitializeSecurityContext ret %#lx\n", status );
|
||||
|
||||
if(status == SEC_E_OK) {
|
||||
if(in_bufs[1].BufferType == SECBUFFER_EXTRA)
|
||||
@@ -361,7 +409,7 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
|
||||
res = netconn_verify_cert(cert, hostname, security_flags, check_revocation);
|
||||
CertFreeCertificateContext(cert);
|
||||
if(res != ERROR_SUCCESS) {
|
||||
WARN("cert verify failed: %u\n", res);
|
||||
WARN( "cert verify failed: %lu\n", res );
|
||||
break;
|
||||
}
|
||||
}else {
|
||||
@@ -369,83 +417,108 @@ BOOL netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD securi
|
||||
break;
|
||||
}
|
||||
|
||||
conn->ssl_buf = heap_alloc(conn->ssl_sizes.cbHeader + conn->ssl_sizes.cbMaximumMessage + conn->ssl_sizes.cbTrailer);
|
||||
if(!conn->ssl_buf) {
|
||||
res = GetLastError();
|
||||
conn->ssl_read_buf = malloc(conn->ssl_sizes.cbHeader + conn->ssl_sizes.cbMaximumMessage + conn->ssl_sizes.cbTrailer);
|
||||
if(!conn->ssl_read_buf) {
|
||||
res = ERROR_OUTOFMEMORY;
|
||||
break;
|
||||
}
|
||||
conn->ssl_write_buf = malloc(conn->ssl_sizes.cbHeader + conn->ssl_sizes.cbMaximumMessage + conn->ssl_sizes.cbTrailer);
|
||||
if(!conn->ssl_write_buf) {
|
||||
res = ERROR_OUTOFMEMORY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
heap_free(read_buf);
|
||||
free(read_buf);
|
||||
|
||||
if(status != SEC_E_OK || res != ERROR_SUCCESS) {
|
||||
WARN("Failed to initialize security context failed: %08x\n", status);
|
||||
heap_free(conn->ssl_buf);
|
||||
conn->ssl_buf = NULL;
|
||||
WARN( "Failed to initialize security context: %#lx\n", status );
|
||||
free(conn->ssl_read_buf);
|
||||
conn->ssl_read_buf = NULL;
|
||||
free(conn->ssl_write_buf);
|
||||
conn->ssl_write_buf = NULL;
|
||||
DeleteSecurityContext(&ctx);
|
||||
SetLastError(res ? res : ERROR_WINHTTP_SECURE_CHANNEL_ERROR);
|
||||
return FALSE;
|
||||
return ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
TRACE("established SSL connection\n");
|
||||
conn->secure = TRUE;
|
||||
conn->ssl_ctx = ctx;
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOL send_ssl_chunk(struct netconn *conn, const void *msg, size_t size)
|
||||
static DWORD send_ssl_chunk( struct netconn *conn, const void *msg, size_t size, WSAOVERLAPPED *ovr )
|
||||
{
|
||||
SecBuffer bufs[4] = {
|
||||
{conn->ssl_sizes.cbHeader, SECBUFFER_STREAM_HEADER, conn->ssl_buf},
|
||||
{size, SECBUFFER_DATA, conn->ssl_buf+conn->ssl_sizes.cbHeader},
|
||||
{conn->ssl_sizes.cbTrailer, SECBUFFER_STREAM_TRAILER, conn->ssl_buf+conn->ssl_sizes.cbHeader+size},
|
||||
{conn->ssl_sizes.cbHeader, SECBUFFER_STREAM_HEADER, conn->ssl_write_buf},
|
||||
{size, SECBUFFER_DATA, conn->ssl_write_buf+conn->ssl_sizes.cbHeader},
|
||||
{conn->ssl_sizes.cbTrailer, SECBUFFER_STREAM_TRAILER, conn->ssl_write_buf+conn->ssl_sizes.cbHeader+size},
|
||||
{0, SECBUFFER_EMPTY, NULL}
|
||||
};
|
||||
SecBufferDesc buf_desc = {SECBUFFER_VERSION, ARRAY_SIZE(bufs), bufs};
|
||||
SECURITY_STATUS res;
|
||||
|
||||
memcpy(bufs[1].pvBuffer, msg, size);
|
||||
res = EncryptMessage(&conn->ssl_ctx, 0, &buf_desc, 0);
|
||||
if(res != SEC_E_OK) {
|
||||
WARN("EncryptMessage failed\n");
|
||||
return FALSE;
|
||||
memcpy( bufs[1].pvBuffer, msg, size );
|
||||
if ((res = EncryptMessage(&conn->ssl_ctx, 0, &buf_desc, 0)) != SEC_E_OK)
|
||||
{
|
||||
WARN( "EncryptMessage failed: %#lx\n", res );
|
||||
return res;
|
||||
}
|
||||
|
||||
if(sock_send(conn->socket, conn->ssl_buf, bufs[0].cbBuffer+bufs[1].cbBuffer+bufs[2].cbBuffer, 0) < 1) {
|
||||
if (sock_send( conn->socket, conn->ssl_write_buf, bufs[0].cbBuffer + bufs[1].cbBuffer + bufs[2].cbBuffer, ovr ) < 1)
|
||||
{
|
||||
WARN("send failed\n");
|
||||
return FALSE;
|
||||
return WSAGetLastError();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
BOOL netconn_send( struct netconn *conn, const void *msg, size_t len, int *sent )
|
||||
DWORD netconn_send( struct netconn *conn, const void *msg, size_t len, int *sent, WSAOVERLAPPED *ovr )
|
||||
{
|
||||
DWORD err;
|
||||
|
||||
if (ovr && !conn->port)
|
||||
{
|
||||
if (!(conn->port = CreateIoCompletionPort( (HANDLE)(SOCKET)conn->socket, NULL, (ULONG_PTR)conn->socket, 0 )))
|
||||
ERR( "Failed to create port.\n" );
|
||||
}
|
||||
|
||||
if (conn->secure)
|
||||
{
|
||||
const BYTE *ptr = msg;
|
||||
size_t chunk_size;
|
||||
DWORD res;
|
||||
|
||||
*sent = 0;
|
||||
|
||||
while(len) {
|
||||
chunk_size = min(len, conn->ssl_sizes.cbMaximumMessage);
|
||||
if(!send_ssl_chunk(conn, ptr, chunk_size))
|
||||
return FALSE;
|
||||
|
||||
while (len)
|
||||
{
|
||||
chunk_size = min( len, conn->ssl_sizes.cbMaximumMessage );
|
||||
if ((res = send_ssl_chunk( conn, ptr, chunk_size, ovr )))
|
||||
{
|
||||
if (res == WSA_IO_PENDING) *sent += chunk_size;
|
||||
return res;
|
||||
}
|
||||
*sent += chunk_size;
|
||||
ptr += chunk_size;
|
||||
len -= chunk_size;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
return ((*sent = sock_send( conn->socket, msg, len, 0 )) != -1);
|
||||
|
||||
if ((*sent = sock_send( conn->socket, msg, len, ovr )) < 0)
|
||||
{
|
||||
err = WSAGetLastError();
|
||||
*sent = (err == WSA_IO_PENDING) ? len : 0;
|
||||
return err;
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof)
|
||||
static DWORD read_ssl_chunk( struct netconn *conn, void *buf, SIZE_T buf_size, SIZE_T *ret_size, BOOL *eof )
|
||||
{
|
||||
const SIZE_T ssl_buf_size = conn->ssl_sizes.cbHeader+conn->ssl_sizes.cbMaximumMessage+conn->ssl_sizes.cbTrailer;
|
||||
SecBuffer bufs[4];
|
||||
@@ -457,19 +530,19 @@ static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZ
|
||||
assert(conn->extra_len < ssl_buf_size);
|
||||
|
||||
if(conn->extra_len) {
|
||||
memcpy(conn->ssl_buf, conn->extra_buf, conn->extra_len);
|
||||
memcpy(conn->ssl_read_buf, conn->extra_buf, conn->extra_len);
|
||||
buf_len = conn->extra_len;
|
||||
conn->extra_len = 0;
|
||||
heap_free(conn->extra_buf);
|
||||
free(conn->extra_buf);
|
||||
conn->extra_buf = NULL;
|
||||
}else {
|
||||
buf_len = sock_recv(conn->socket, conn->ssl_buf+conn->extra_len, ssl_buf_size-conn->extra_len, 0);
|
||||
if(buf_len < 0)
|
||||
return FALSE;
|
||||
if ((buf_len = sock_recv( conn->socket, conn->ssl_read_buf + conn->extra_len, ssl_buf_size - conn->extra_len, 0)) < 0)
|
||||
return WSAGetLastError();
|
||||
|
||||
if(!buf_len) {
|
||||
if (!buf_len)
|
||||
{
|
||||
*eof = TRUE;
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -480,30 +553,36 @@ static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZ
|
||||
memset(bufs, 0, sizeof(bufs));
|
||||
bufs[0].BufferType = SECBUFFER_DATA;
|
||||
bufs[0].cbBuffer = buf_len;
|
||||
bufs[0].pvBuffer = conn->ssl_buf;
|
||||
bufs[0].pvBuffer = conn->ssl_read_buf;
|
||||
|
||||
res = DecryptMessage(&conn->ssl_ctx, &buf_desc, 0, NULL);
|
||||
switch(res) {
|
||||
switch ((res = DecryptMessage( &conn->ssl_ctx, &buf_desc, 0, NULL )))
|
||||
{
|
||||
case SEC_E_OK:
|
||||
break;
|
||||
|
||||
case SEC_I_RENEGOTIATE:
|
||||
TRACE("renegotiate\n");
|
||||
return ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED;
|
||||
|
||||
case SEC_I_CONTEXT_EXPIRED:
|
||||
TRACE("context expired\n");
|
||||
*eof = TRUE;
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
case SEC_E_INCOMPLETE_MESSAGE:
|
||||
assert(buf_len < ssl_buf_size);
|
||||
|
||||
size = sock_recv(conn->socket, conn->ssl_buf+buf_len, ssl_buf_size-buf_len, 0);
|
||||
if(size < 1)
|
||||
return FALSE;
|
||||
if ((size = sock_recv( conn->socket, conn->ssl_read_buf + buf_len, ssl_buf_size - buf_len, 0 )) < 1)
|
||||
return SEC_E_INCOMPLETE_MESSAGE;
|
||||
|
||||
buf_len += size;
|
||||
continue;
|
||||
|
||||
default:
|
||||
WARN("failed: %08x\n", res);
|
||||
return FALSE;
|
||||
WARN( "failed: %#lx\n", res );
|
||||
return res;
|
||||
}
|
||||
} while(res != SEC_E_OK);
|
||||
} while (res != SEC_E_OK);
|
||||
|
||||
for(i = 0; i < ARRAY_SIZE(bufs); i++) {
|
||||
if(bufs[i].BufferType == SECBUFFER_DATA) {
|
||||
@@ -511,9 +590,9 @@ static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZ
|
||||
memcpy(buf, bufs[i].pvBuffer, size);
|
||||
if(size < bufs[i].cbBuffer) {
|
||||
assert(!conn->peek_len);
|
||||
conn->peek_msg_mem = conn->peek_msg = heap_alloc(bufs[i].cbBuffer - size);
|
||||
conn->peek_msg_mem = conn->peek_msg = malloc(bufs[i].cbBuffer - size);
|
||||
if(!conn->peek_msg)
|
||||
return FALSE;
|
||||
return ERROR_OUTOFMEMORY;
|
||||
conn->peek_len = bufs[i].cbBuffer-size;
|
||||
memcpy(conn->peek_msg, (char*)bufs[i].pvBuffer+size, conn->peek_len);
|
||||
}
|
||||
@@ -524,27 +603,28 @@ static BOOL read_ssl_chunk(struct netconn *conn, void *buf, SIZE_T buf_size, SIZ
|
||||
|
||||
for(i = 0; i < ARRAY_SIZE(bufs); i++) {
|
||||
if(bufs[i].BufferType == SECBUFFER_EXTRA) {
|
||||
conn->extra_buf = heap_alloc(bufs[i].cbBuffer);
|
||||
conn->extra_buf = malloc(bufs[i].cbBuffer);
|
||||
if(!conn->extra_buf)
|
||||
return FALSE;
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
conn->extra_len = bufs[i].cbBuffer;
|
||||
memcpy(conn->extra_buf, bufs[i].pvBuffer, conn->extra_len);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
BOOL netconn_recv( struct netconn *conn, void *buf, size_t len, int flags, int *recvd )
|
||||
DWORD netconn_recv( struct netconn *conn, void *buf, size_t len, int flags, int *recvd )
|
||||
{
|
||||
*recvd = 0;
|
||||
if (!len) return TRUE;
|
||||
if (!len) return ERROR_SUCCESS;
|
||||
|
||||
if (conn->secure)
|
||||
{
|
||||
SIZE_T size, cread;
|
||||
BOOL res, eof;
|
||||
SIZE_T size;
|
||||
DWORD res;
|
||||
BOOL eof;
|
||||
|
||||
if (conn->peek_msg)
|
||||
{
|
||||
@@ -555,37 +635,47 @@ BOOL netconn_recv( struct netconn *conn, void *buf, size_t len, int flags, int *
|
||||
|
||||
if (conn->peek_len == 0)
|
||||
{
|
||||
heap_free( conn->peek_msg_mem );
|
||||
free( conn->peek_msg_mem );
|
||||
conn->peek_msg_mem = NULL;
|
||||
conn->peek_msg = NULL;
|
||||
}
|
||||
/* check if we have enough data from the peek buffer */
|
||||
if (!(flags & MSG_WAITALL) || *recvd == len) return TRUE;
|
||||
if (!(flags & MSG_WAITALL) || *recvd == len) return ERROR_SUCCESS;
|
||||
}
|
||||
size = *recvd;
|
||||
|
||||
do {
|
||||
res = read_ssl_chunk(conn, (BYTE*)buf+size, len-size, &cread, &eof);
|
||||
if(!res) {
|
||||
WARN("read_ssl_chunk failed\n");
|
||||
if(!size)
|
||||
return FALSE;
|
||||
do
|
||||
{
|
||||
SIZE_T cread = 0;
|
||||
if ((res = read_ssl_chunk( conn, (BYTE *)buf + size, len - size, &cread, &eof )))
|
||||
{
|
||||
WARN( "read_ssl_chunk failed: %lu\n", res );
|
||||
if (!size) return res;
|
||||
break;
|
||||
}
|
||||
|
||||
if(eof) {
|
||||
if (eof)
|
||||
{
|
||||
TRACE("EOF\n");
|
||||
break;
|
||||
}
|
||||
|
||||
size += cread;
|
||||
}while(!size || ((flags & MSG_WAITALL) && size < len));
|
||||
|
||||
TRACE("received %ld bytes\n", size);
|
||||
} while (!size || ((flags & MSG_WAITALL) && size < len));
|
||||
|
||||
TRACE( "received %Iu bytes\n", size );
|
||||
*recvd = size;
|
||||
return TRUE;
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
return ((*recvd = sock_recv( conn->socket, buf, len, flags )) != -1);
|
||||
|
||||
if ((*recvd = sock_recv( conn->socket, buf, len, flags )) < 0) return WSAGetLastError();
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
void netconn_cancel_io( struct netconn *conn )
|
||||
{
|
||||
SOCKET socket = InterlockedExchange( (LONG *)&conn->socket, -1 );
|
||||
|
||||
closesocket( socket );
|
||||
}
|
||||
|
||||
ULONG netconn_query_data_available( struct netconn *conn )
|
||||
@@ -599,7 +689,7 @@ DWORD netconn_set_timeout( struct netconn *netconn, BOOL send, int value )
|
||||
if (setsockopt( netconn->socket, SOL_SOCKET, opt, (void *)&value, sizeof(value) ) == -1)
|
||||
{
|
||||
DWORD err = WSAGetLastError();
|
||||
WARN("setsockopt failed (%u)\n", err );
|
||||
WARN( "setsockopt failed (%lu)\n", err );
|
||||
return err;
|
||||
}
|
||||
return ERROR_SUCCESS;
|
||||
@@ -607,11 +697,31 @@ DWORD netconn_set_timeout( struct netconn *netconn, BOOL send, int value )
|
||||
|
||||
BOOL netconn_is_alive( struct netconn *netconn )
|
||||
{
|
||||
SIZE_T size;
|
||||
int len;
|
||||
char b;
|
||||
DWORD err;
|
||||
BOOL eof;
|
||||
|
||||
set_blocking( netconn, FALSE );
|
||||
if (netconn->secure)
|
||||
{
|
||||
while (!netconn->peek_msg && !(err = read_ssl_chunk( netconn, NULL, 0, &size, &eof )) && !eof)
|
||||
;
|
||||
|
||||
TRACE( "checking secure connection, err %lu\n", err );
|
||||
|
||||
if (netconn->peek_msg || err == WSAEWOULDBLOCK)
|
||||
{
|
||||
set_blocking( netconn, TRUE );
|
||||
return TRUE;
|
||||
}
|
||||
if (err != SEC_E_OK && err != SEC_E_INCOMPLETE_MESSAGE)
|
||||
{
|
||||
set_blocking( netconn, TRUE );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
len = sock_recv( netconn->socket, &b, 1, MSG_PEEK );
|
||||
err = WSAGetLastError();
|
||||
set_blocking( netconn, TRUE );
|
||||
@@ -657,104 +767,86 @@ static DWORD resolve_hostname( const WCHAR *name, INTERNET_PORT port, struct soc
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
#ifdef __REACTOS__
|
||||
|
||||
struct resolve_args
|
||||
{
|
||||
const WCHAR *hostname;
|
||||
INTERNET_PORT port;
|
||||
struct sockaddr_storage *sa;
|
||||
};
|
||||
|
||||
static DWORD CALLBACK resolve_proc( LPVOID arg )
|
||||
{
|
||||
struct resolve_args *ra = arg;
|
||||
return resolve_hostname( ra->hostname, ra->port, ra->sa );
|
||||
}
|
||||
|
||||
BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *sa, int timeout )
|
||||
{
|
||||
DWORD ret;
|
||||
|
||||
if (timeout)
|
||||
{
|
||||
DWORD status;
|
||||
HANDLE thread;
|
||||
struct resolve_args ra;
|
||||
|
||||
ra.hostname = hostname;
|
||||
ra.port = port;
|
||||
ra.sa = sa;
|
||||
|
||||
thread = CreateThread( NULL, 0, resolve_proc, &ra, 0, NULL );
|
||||
if (!thread) return FALSE;
|
||||
|
||||
status = WaitForSingleObject( thread, timeout );
|
||||
if (status == WAIT_OBJECT_0) GetExitCodeThread( thread, &ret );
|
||||
else ret = ERROR_WINHTTP_TIMEOUT;
|
||||
CloseHandle( thread );
|
||||
}
|
||||
else ret = resolve_hostname( hostname, port, sa );
|
||||
|
||||
if (ret)
|
||||
{
|
||||
SetLastError( ret );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#else /* __REACTOS__ */
|
||||
|
||||
struct async_resolve
|
||||
{
|
||||
const WCHAR *hostname;
|
||||
LONG ref;
|
||||
WCHAR *hostname;
|
||||
INTERNET_PORT port;
|
||||
struct sockaddr_storage *addr;
|
||||
struct sockaddr_storage addr;
|
||||
DWORD result;
|
||||
HANDLE done;
|
||||
};
|
||||
|
||||
static struct async_resolve *create_async_resolve( const WCHAR *hostname, INTERNET_PORT port )
|
||||
{
|
||||
struct async_resolve *ret;
|
||||
|
||||
if (!(ret = malloc(sizeof(*ret))))
|
||||
{
|
||||
ERR( "No memory.\n" );
|
||||
return NULL;
|
||||
}
|
||||
ret->ref = 1;
|
||||
ret->hostname = wcsdup( hostname );
|
||||
ret->port = port;
|
||||
if (!(ret->done = CreateEventW( NULL, FALSE, FALSE, NULL )))
|
||||
{
|
||||
free( ret->hostname );
|
||||
free( ret );
|
||||
return NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void async_resolve_release( struct async_resolve *async )
|
||||
{
|
||||
if (InterlockedDecrement( &async->ref )) return;
|
||||
|
||||
free( async->hostname );
|
||||
CloseHandle( async->done );
|
||||
free( async );
|
||||
}
|
||||
|
||||
static void CALLBACK resolve_proc( TP_CALLBACK_INSTANCE *instance, void *ctx )
|
||||
{
|
||||
struct async_resolve *async = ctx;
|
||||
async->result = resolve_hostname( async->hostname, async->port, async->addr );
|
||||
|
||||
async->result = resolve_hostname( async->hostname, async->port, &async->addr );
|
||||
SetEvent( async->done );
|
||||
async_resolve_release( async );
|
||||
}
|
||||
|
||||
BOOL netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *addr, int timeout )
|
||||
DWORD netconn_resolve( WCHAR *hostname, INTERNET_PORT port, struct sockaddr_storage *addr, int timeout )
|
||||
{
|
||||
DWORD ret;
|
||||
|
||||
if (!timeout) ret = resolve_hostname( hostname, port, addr );
|
||||
else
|
||||
{
|
||||
struct async_resolve async;
|
||||
struct async_resolve *async;
|
||||
|
||||
async.hostname = hostname;
|
||||
async.port = port;
|
||||
async.addr = addr;
|
||||
if (!(async.done = CreateEventW( NULL, FALSE, FALSE, NULL ))) return FALSE;
|
||||
if (!TrySubmitThreadpoolCallback( resolve_proc, &async, NULL ))
|
||||
if (!(async = create_async_resolve( hostname, port )))
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
InterlockedIncrement( &async->ref );
|
||||
if (!TrySubmitThreadpoolCallback( resolve_proc, async, NULL ))
|
||||
{
|
||||
CloseHandle( async.done );
|
||||
return FALSE;
|
||||
InterlockedDecrement( &async->ref );
|
||||
async_resolve_release( async );
|
||||
return GetLastError();
|
||||
}
|
||||
if (WaitForSingleObject( async.done, timeout ) != WAIT_OBJECT_0) ret = ERROR_WINHTTP_TIMEOUT;
|
||||
else ret = async.result;
|
||||
CloseHandle( async.done );
|
||||
if (WaitForSingleObject( async->done, timeout ) != WAIT_OBJECT_0) ret = ERROR_WINHTTP_TIMEOUT;
|
||||
else
|
||||
{
|
||||
*addr = async->addr;
|
||||
ret = async->result;
|
||||
}
|
||||
async_resolve_release( async );
|
||||
}
|
||||
|
||||
if (ret)
|
||||
{
|
||||
SetLastError( ret );
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif /* __REACTOS__ */
|
||||
|
||||
const void *netconn_get_certificate( struct netconn *conn )
|
||||
{
|
||||
const CERT_CONTEXT *ret;
|
||||
@@ -773,6 +865,6 @@ int netconn_get_cipher_strength( struct netconn *conn )
|
||||
if (!conn->secure) return 0;
|
||||
res = QueryContextAttributesW(&conn->ssl_ctx, SECPKG_ATTR_CONNECTION_INFO, (void*)&conn_info);
|
||||
if(res != SEC_E_OK)
|
||||
WARN("QueryContextAttributesW failed: %08x\n", res);
|
||||
WARN( "QueryContextAttributesW failed: %#lx\n", res );
|
||||
return res == SEC_E_OK ? conn_info.dwCipherStrength : 0;
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@
|
||||
#define COM_NO_WINDOWS_H
|
||||
|
||||
#define COBJMACROS
|
||||
#define NONAMELESSUNION
|
||||
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <ole2.h>
|
||||
#include <winsock2.h>
|
||||
#include <winhttp.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <wine/debug.h>
|
||||
|
||||
|
||||
+2462
-1089
File diff suppressed because it is too large
Load Diff
+823
-450
File diff suppressed because it is too large
Load Diff
+54
-52
@@ -16,12 +16,10 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#include <wchar.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "ws2tcpip.h"
|
||||
#include "winreg.h"
|
||||
#include "winhttp.h"
|
||||
#include "shlwapi.h"
|
||||
@@ -31,9 +29,6 @@
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(winhttp);
|
||||
|
||||
static const WCHAR scheme_http[] = {'h','t','t','p',0};
|
||||
static const WCHAR scheme_https[] = {'h','t','t','p','s',0};
|
||||
|
||||
struct url_component
|
||||
{
|
||||
WCHAR **str;
|
||||
@@ -70,16 +65,16 @@ static WCHAR *decode_url( LPCWSTR url, DWORD *len )
|
||||
const WCHAR *p = url;
|
||||
WCHAR hex[3], *q, *ret;
|
||||
|
||||
if (!(ret = heap_alloc( *len * sizeof(WCHAR) ))) return NULL;
|
||||
if (!(ret = malloc( *len * sizeof(WCHAR) ))) return NULL;
|
||||
q = ret;
|
||||
while (*len > 0)
|
||||
{
|
||||
if (p[0] == '%' && isxdigitW( p[1] ) && isxdigitW( p[2] ))
|
||||
if (p[0] == '%' && iswxdigit( p[1] ) && iswxdigit( p[2] ))
|
||||
{
|
||||
hex[0] = p[1];
|
||||
hex[1] = p[2];
|
||||
hex[2] = 0;
|
||||
*q++ = strtolW( hex, NULL, 16 );
|
||||
*q++ = wcstol( hex, NULL, 16 );
|
||||
p += 3;
|
||||
*len -= 3;
|
||||
}
|
||||
@@ -95,8 +90,7 @@ static WCHAR *decode_url( LPCWSTR url, DWORD *len )
|
||||
|
||||
static inline BOOL need_escape( WCHAR ch )
|
||||
{
|
||||
static const WCHAR escapes[] = {' ','"','#','%','<','>','[','\\',']','^','`','{','|','}','~',0};
|
||||
const WCHAR *p = escapes;
|
||||
const WCHAR *p = L" \"#%<>[\\]^`{|}~";
|
||||
|
||||
if (ch <= 31 || ch >= 127) return TRUE;
|
||||
while (*p)
|
||||
@@ -108,7 +102,7 @@ static inline BOOL need_escape( WCHAR ch )
|
||||
|
||||
static BOOL escape_string( const WCHAR *src, DWORD src_len, WCHAR *dst, DWORD *dst_len )
|
||||
{
|
||||
static const WCHAR hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||
static const WCHAR hex[] = L"0123456789ABCDEF";
|
||||
WCHAR *p = dst;
|
||||
DWORD i;
|
||||
|
||||
@@ -139,7 +133,7 @@ static DWORD escape_url( const WCHAR *url, DWORD *len, WCHAR **ret )
|
||||
const WCHAR *p;
|
||||
DWORD len_base, len_path;
|
||||
|
||||
if ((p = strrchrW( url, '/' )))
|
||||
if ((p = wcsrchr( url, '/' )))
|
||||
{
|
||||
len_base = p - url;
|
||||
if (!escape_string( p, *len - len_base, NULL, &len_path )) return ERROR_INVALID_PARAMETER;
|
||||
@@ -150,7 +144,7 @@ static DWORD escape_url( const WCHAR *url, DWORD *len, WCHAR **ret )
|
||||
len_path = 0;
|
||||
}
|
||||
|
||||
if (!(*ret = heap_alloc( (len_base + len_path + 1) * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
|
||||
if (!(*ret = malloc( (len_base + len_path + 1) * sizeof(WCHAR) ))) return ERROR_OUTOFMEMORY;
|
||||
memcpy( *ret, url, len_base * sizeof(WCHAR) );
|
||||
|
||||
if (p) escape_string( p, *len - (p - url), *ret + len_base, &len_path );
|
||||
@@ -164,7 +158,7 @@ static DWORD parse_port( const WCHAR *str, DWORD len, INTERNET_PORT *ret )
|
||||
{
|
||||
const WCHAR *p = str;
|
||||
DWORD port = 0;
|
||||
while (len && isdigitW( *p ))
|
||||
while (len && '0' <= *p && *p <= '9')
|
||||
{
|
||||
if ((port = port * 10 + *p - '0') > 65535) return ERROR_WINHTTP_INVALID_URL;
|
||||
p++; len--;
|
||||
@@ -176,48 +170,49 @@ static DWORD parse_port( const WCHAR *str, DWORD len, INTERNET_PORT *ret )
|
||||
/***********************************************************************
|
||||
* WinHttpCrackUrl (winhttp.@)
|
||||
*/
|
||||
BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONENTSW uc )
|
||||
BOOL WINAPI WinHttpCrackUrl( const WCHAR *url, DWORD len, DWORD flags, URL_COMPONENTSW *uc )
|
||||
{
|
||||
WCHAR *p, *q, *r, *url_decoded = NULL, *url_escaped = NULL;
|
||||
WCHAR *p, *q, *r, *url_transformed = NULL;
|
||||
INTERNET_SCHEME scheme_number = 0;
|
||||
struct url_component scheme, username, password, hostname, path, extra;
|
||||
BOOL overflow = FALSE;
|
||||
DWORD err;
|
||||
|
||||
TRACE("%s, %d, %x, %p\n", debugstr_wn(url, len), len, flags, uc);
|
||||
TRACE( "%s, %lu, %#lx, %p\n", debugstr_wn(url, len), len, flags, uc );
|
||||
|
||||
if (!url || !uc || uc->dwStructSize != sizeof(*uc))
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return FALSE;
|
||||
}
|
||||
if (!len) len = strlenW( url );
|
||||
if (!len) len = lstrlenW( url );
|
||||
|
||||
if (flags & ICU_ESCAPE)
|
||||
{
|
||||
if ((err = escape_url( url, &len, &url_escaped )))
|
||||
if ((err = escape_url( url, &len, &url_transformed )))
|
||||
{
|
||||
SetLastError( err );
|
||||
return FALSE;
|
||||
}
|
||||
url = url_escaped;
|
||||
url = url_transformed;
|
||||
}
|
||||
else if (flags & ICU_DECODE)
|
||||
{
|
||||
if (!(url_decoded = decode_url( url, &len )))
|
||||
if (!(url_transformed = decode_url( url, &len )))
|
||||
{
|
||||
SetLastError( ERROR_OUTOFMEMORY );
|
||||
return FALSE;
|
||||
}
|
||||
url = url_decoded;
|
||||
url = url_transformed;
|
||||
}
|
||||
if (!(p = strchrW( url, ':' )))
|
||||
if (!(p = wcschr( url, ':' )))
|
||||
{
|
||||
SetLastError( ERROR_WINHTTP_UNRECOGNIZED_SCHEME );
|
||||
free( url_transformed );
|
||||
return FALSE;
|
||||
}
|
||||
if (p - url == 4 && !strncmpiW( url, scheme_http, 4 )) scheme_number = INTERNET_SCHEME_HTTP;
|
||||
else if (p - url == 5 && !strncmpiW( url, scheme_https, 5 )) scheme_number = INTERNET_SCHEME_HTTPS;
|
||||
if (p - url == 4 && !wcsnicmp( url, L"http", 4 )) scheme_number = INTERNET_SCHEME_HTTP;
|
||||
else if (p - url == 5 && !wcsnicmp( url, L"https", 5 )) scheme_number = INTERNET_SCHEME_HTTPS;
|
||||
else
|
||||
{
|
||||
err = ERROR_WINHTTP_UNRECOGNIZED_SCHEME;
|
||||
@@ -248,10 +243,10 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
|
||||
password.str = &uc->lpszPassword;
|
||||
password.len = &uc->dwPasswordLength;
|
||||
|
||||
if ((q = memchrW( p, '@', len - (p - url) )) && !(memchrW( p, '/', q - p )))
|
||||
if ((q = wmemchr( p, '@', len - (p - url) )) && !(wmemchr( p, '/', q - p )))
|
||||
{
|
||||
|
||||
if ((r = memchrW( p, ':', q - p )))
|
||||
if ((r = wmemchr( p, ':', q - p )))
|
||||
{
|
||||
if ((err = set_component( &username, p, r - p, flags, &overflow ))) goto exit;
|
||||
r++;
|
||||
@@ -279,22 +274,27 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
|
||||
extra.str = &uc->lpszExtraInfo;
|
||||
extra.len = &uc->dwExtraInfoLength;
|
||||
|
||||
if ((q = memchrW( p, '/', len - (p - url) )))
|
||||
if ((q = wmemchr( p, '/', len - (p - url) )))
|
||||
{
|
||||
if ((r = memchrW( p, ':', q - p )))
|
||||
if ((r = wmemchr( p, ':', q - p )))
|
||||
{
|
||||
if ((err = set_component( &hostname, p, r - p, flags, &overflow ))) goto exit;
|
||||
r++;
|
||||
if ((err = parse_port( r, q - r, &uc->nPort ))) goto exit;
|
||||
if (!(q - r))
|
||||
{
|
||||
if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
else if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
}
|
||||
else if ((err = parse_port( r, q - r, &uc->nPort ))) goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((err = set_component( &hostname, p, q - p, flags, &overflow ))) goto exit;
|
||||
if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
else if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
}
|
||||
|
||||
if ((r = memchrW( q, '?', len - (q - url) )))
|
||||
if ((r = wmemchr( q, '?', len - (q - url) )))
|
||||
{
|
||||
if (*extra.len)
|
||||
{
|
||||
@@ -311,17 +311,22 @@ BOOL WINAPI WinHttpCrackUrl( LPCWSTR url, DWORD len, DWORD flags, LPURL_COMPONEN
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((r = memchrW( p, ':', len - (p - url) )))
|
||||
if ((r = wmemchr( p, ':', len - (p - url) )))
|
||||
{
|
||||
if ((err = set_component( &hostname, p, r - p, flags, &overflow ))) goto exit;
|
||||
r++;
|
||||
if ((err = parse_port( r, len - (r - url), &uc->nPort ))) goto exit;
|
||||
if (!*r)
|
||||
{
|
||||
if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
else if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
}
|
||||
else if ((err = parse_port( r, len - (r - url), &uc->nPort ))) goto exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((err = set_component( &hostname, p, len - (p - url), flags, &overflow ))) goto exit;
|
||||
if (scheme_number == INTERNET_SCHEME_HTTP) uc->nPort = INTERNET_DEFAULT_HTTP_PORT;
|
||||
if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
else if (scheme_number == INTERNET_SCHEME_HTTPS) uc->nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
||||
}
|
||||
if ((err = set_component( &path, (WCHAR *)url + len, 0, flags, &overflow ))) goto exit;
|
||||
if ((err = set_component( &extra, (WCHAR *)url + len, 0, flags, &overflow ))) goto exit;
|
||||
@@ -337,23 +342,22 @@ exit:
|
||||
if (overflow) err = ERROR_INSUFFICIENT_BUFFER;
|
||||
uc->nScheme = scheme_number;
|
||||
}
|
||||
heap_free( url_decoded );
|
||||
heap_free( url_escaped );
|
||||
free( url_transformed );
|
||||
SetLastError( err );
|
||||
return !err;
|
||||
}
|
||||
|
||||
static INTERNET_SCHEME get_scheme( const WCHAR *scheme, DWORD len )
|
||||
{
|
||||
if (!strncmpW( scheme, scheme_http, len )) return INTERNET_SCHEME_HTTP;
|
||||
if (!strncmpW( scheme, scheme_https, len )) return INTERNET_SCHEME_HTTPS;
|
||||
if (!wcsncmp( scheme, L"http", len )) return INTERNET_SCHEME_HTTP;
|
||||
if (!wcsncmp( scheme, L"https", len )) return INTERNET_SCHEME_HTTPS;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const WCHAR *get_scheme_string( INTERNET_SCHEME scheme )
|
||||
{
|
||||
if (scheme == INTERNET_SCHEME_HTTP) return scheme_http;
|
||||
if (scheme == INTERNET_SCHEME_HTTPS) return scheme_https;
|
||||
if (scheme == INTERNET_SCHEME_HTTP) return L"http";
|
||||
if (scheme == INTERNET_SCHEME_HTTPS) return L"https";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -369,7 +373,7 @@ static DWORD get_comp_length( DWORD len, DWORD flags, WCHAR *comp )
|
||||
DWORD ret;
|
||||
unsigned int i;
|
||||
|
||||
ret = len ? len : strlenW( comp );
|
||||
ret = len ? len : lstrlenW( comp );
|
||||
if (!(flags & ICU_ESCAPE)) return ret;
|
||||
for (i = 0; i < len; i++) if (need_escape( comp[i] )) ret += 2;
|
||||
return ret;
|
||||
@@ -377,7 +381,6 @@ static DWORD get_comp_length( DWORD len, DWORD flags, WCHAR *comp )
|
||||
|
||||
static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
|
||||
{
|
||||
static const WCHAR formatW[] = {'%','u',0};
|
||||
INTERNET_SCHEME scheme;
|
||||
|
||||
*len = 0;
|
||||
@@ -391,7 +394,7 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
|
||||
{
|
||||
scheme = uc->nScheme;
|
||||
if (!scheme) scheme = INTERNET_SCHEME_HTTP;
|
||||
*len += strlenW( get_scheme_string( scheme ) );
|
||||
*len += lstrlenW( get_scheme_string( scheme ) );
|
||||
}
|
||||
*len += 3; /* "://" */
|
||||
|
||||
@@ -421,7 +424,7 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
|
||||
{
|
||||
WCHAR port[sizeof("65535")];
|
||||
|
||||
*len += sprintfW( port, formatW, uc->nPort );
|
||||
*len += swprintf( port, ARRAY_SIZE(port), L"%u", uc->nPort );
|
||||
*len += 1; /* ":" */
|
||||
}
|
||||
if (uc->lpszUrlPath && *uc->lpszUrlPath != '/') *len += 1; /* '/' */
|
||||
@@ -434,13 +437,12 @@ static BOOL get_url_length( URL_COMPONENTS *uc, DWORD flags, DWORD *len )
|
||||
/***********************************************************************
|
||||
* WinHttpCreateUrl (winhttp.@)
|
||||
*/
|
||||
BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDWORD required )
|
||||
BOOL WINAPI WinHttpCreateUrl( URL_COMPONENTS *uc, DWORD flags, WCHAR *url, DWORD *required )
|
||||
{
|
||||
static const WCHAR formatW[] = {'%','u',0};
|
||||
DWORD len, len_escaped;
|
||||
INTERNET_SCHEME scheme;
|
||||
|
||||
TRACE("%p, 0x%08x, %p, %p\n", uc, flags, url, required);
|
||||
TRACE( "%p, %#lx, %p, %p\n", uc, flags, url, required );
|
||||
|
||||
if (!uc || uc->dwStructSize != sizeof(URL_COMPONENTS) || !required)
|
||||
{
|
||||
@@ -480,7 +482,7 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
|
||||
if (!scheme) scheme = INTERNET_SCHEME_HTTP;
|
||||
|
||||
schemeW = get_scheme_string( scheme );
|
||||
len = strlenW( schemeW );
|
||||
len = lstrlenW( schemeW );
|
||||
memcpy( url, schemeW, len * sizeof(WCHAR) );
|
||||
url += len;
|
||||
}
|
||||
@@ -513,7 +515,7 @@ BOOL WINAPI WinHttpCreateUrl( LPURL_COMPONENTS uc, DWORD flags, LPWSTR url, LPDW
|
||||
if (!uses_default_port( scheme, uc->nPort ))
|
||||
{
|
||||
*url++ = ':';
|
||||
url += sprintfW( url, formatW, uc->nPort );
|
||||
url += swprintf( url, sizeof("65535"), L"%u", uc->nPort );
|
||||
}
|
||||
|
||||
/* add slash between hostname and path if necessary */
|
||||
|
||||
@@ -7,11 +7,20 @@
|
||||
@ stdcall WinHttpCloseHandle(ptr)
|
||||
@ stdcall WinHttpConnect(ptr wstr long long)
|
||||
@ stdcall WinHttpCrackUrl(wstr long long ptr)
|
||||
@ stdcall WinHttpCreateProxyResolver(ptr ptr)
|
||||
@ stdcall WinHttpCreateUrl(ptr long ptr ptr)
|
||||
@ stdcall WinHttpDetectAutoProxyConfigUrl(long ptr)
|
||||
@ stdcall WinHttpFreeProxyResult(ptr)
|
||||
@ stdcall WinHttpFreeProxyResultEx(ptr)
|
||||
@ stdcall WinHttpFreeProxySettings(ptr)
|
||||
@ stdcall WinHttpGetDefaultProxyConfiguration(ptr)
|
||||
@ stdcall WinHttpGetIEProxyConfigForCurrentUser(ptr)
|
||||
@ stdcall WinHttpGetProxyForUrl(ptr wstr ptr ptr)
|
||||
@ stdcall WinHttpGetProxyForUrlEx(ptr wstr ptr ptr)
|
||||
@ stdcall WinHttpGetProxyForUrlEx2(ptr wstr ptr long ptr ptr)
|
||||
@ stdcall WinHttpGetProxyResult(ptr ptr)
|
||||
@ stdcall WinHttpGetProxyResultEx(ptr ptr)
|
||||
@ stdcall WinHttpGetProxySettingsVersion(ptr ptr)
|
||||
@ stdcall WinHttpOpen(wstr long wstr wstr long)
|
||||
@ stdcall WinHttpOpenRequest(ptr wstr wstr wstr wstr ptr long)
|
||||
@ stdcall WinHttpQueryAuthSchemes(ptr ptr ptr ptr)
|
||||
@@ -19,7 +28,9 @@
|
||||
@ stdcall WinHttpQueryHeaders(ptr long wstr ptr ptr ptr)
|
||||
@ stdcall WinHttpQueryOption(ptr long ptr ptr)
|
||||
@ stdcall WinHttpReadData(ptr ptr long ptr)
|
||||
@ stdcall WinHttpReadProxySettings(ptr wstr long long ptr ptr ptr)
|
||||
@ stdcall WinHttpReceiveResponse(ptr ptr)
|
||||
@ stdcall WinHttpResetAutoProxy(ptr long)
|
||||
@ stdcall WinHttpSendRequest(ptr wstr long ptr long long long)
|
||||
@ stdcall WinHttpSetCredentials(ptr long long wstr ptr ptr)
|
||||
@ stdcall WinHttpSetDefaultProxyConfiguration(ptr)
|
||||
@@ -28,4 +39,11 @@
|
||||
@ stdcall WinHttpSetTimeouts(ptr long long long long)
|
||||
@ stdcall WinHttpTimeFromSystemTime(ptr ptr)
|
||||
@ stdcall WinHttpTimeToSystemTime(wstr ptr)
|
||||
@ stdcall WinHttpWebSocketClose(ptr long ptr long)
|
||||
@ stdcall WinHttpWebSocketCompleteUpgrade(ptr ptr)
|
||||
@ stdcall WinHttpWebSocketQueryCloseStatus(ptr ptr ptr long ptr)
|
||||
@ stdcall WinHttpWebSocketReceive(ptr ptr long ptr ptr)
|
||||
@ stdcall WinHttpWebSocketSend(ptr long ptr long)
|
||||
@ stdcall WinHttpWebSocketShutdown(ptr long ptr long)
|
||||
@ stdcall WinHttpWriteData(ptr ptr long ptr)
|
||||
@ stdcall WinHttpWriteProxySettings(ptr long ptr)
|
||||
|
||||
@@ -19,29 +19,25 @@
|
||||
#ifndef _WINE_WINHTTP_PRIVATE_H_
|
||||
#define _WINE_WINHTTP_PRIVATE_H_
|
||||
|
||||
#ifndef __WINE_CONFIG_H
|
||||
# error You must include config.h to use this header
|
||||
#endif
|
||||
|
||||
#include "wine/heap.h"
|
||||
#include "wine/list.h"
|
||||
#include "wine/unicode.h"
|
||||
#include <wine/heap.h>
|
||||
|
||||
#include "ole2.h"
|
||||
#include "sspi.h"
|
||||
#include "wincrypt.h"
|
||||
|
||||
static const WCHAR getW[] = {'G','E','T',0};
|
||||
static const WCHAR postW[] = {'P','O','S','T',0};
|
||||
static const WCHAR headW[] = {'H','E','A','D',0};
|
||||
static const WCHAR slashW[] = {'/',0};
|
||||
static const WCHAR http1_0[] = {'H','T','T','P','/','1','.','0',0};
|
||||
static const WCHAR http1_1[] = {'H','T','T','P','/','1','.','1',0};
|
||||
static const WCHAR chunkedW[] = {'c','h','u','n','k','e','d',0};
|
||||
#ifdef __REACTOS__
|
||||
#include <string.h>
|
||||
#include <winnls.h>
|
||||
#endif
|
||||
|
||||
#include "wine/list.h"
|
||||
|
||||
#define WINHTTP_HANDLE_TYPE_SOCKET 4
|
||||
|
||||
struct object_header;
|
||||
struct object_vtbl
|
||||
{
|
||||
void (*handle_closing) ( struct object_header * );
|
||||
void (*destroy)( struct object_header * );
|
||||
BOOL (*query_option)( struct object_header *, DWORD, void *, DWORD * );
|
||||
BOOL (*set_option)( struct object_header *, DWORD, void *, DWORD );
|
||||
@@ -61,8 +57,10 @@ struct object_header
|
||||
LONG refs;
|
||||
WINHTTP_STATUS_CALLBACK callback;
|
||||
DWORD notify_mask;
|
||||
LONG recursion_count;
|
||||
struct list entry;
|
||||
struct list children;
|
||||
volatile LONG pending_sends;
|
||||
volatile LONG pending_receives;
|
||||
};
|
||||
|
||||
struct hostdata
|
||||
@@ -94,6 +92,8 @@ struct session
|
||||
HANDLE unload_event;
|
||||
DWORD secure_protocols;
|
||||
DWORD passport_flags;
|
||||
unsigned int websocket_receive_buffer_size;
|
||||
unsigned int websocket_send_buffer_size;
|
||||
};
|
||||
|
||||
struct connect
|
||||
@@ -113,6 +113,7 @@ struct connect
|
||||
struct netconn
|
||||
{
|
||||
struct list entry;
|
||||
LONG refs;
|
||||
int socket;
|
||||
struct sockaddr_storage sockaddr;
|
||||
BOOL secure; /* SSL active on connection? */
|
||||
@@ -120,12 +121,13 @@ struct netconn
|
||||
ULONGLONG keep_until;
|
||||
CtxtHandle ssl_ctx;
|
||||
SecPkgContext_StreamSizes ssl_sizes;
|
||||
char *ssl_buf;
|
||||
char *ssl_read_buf, *ssl_write_buf;
|
||||
char *extra_buf;
|
||||
size_t extra_len;
|
||||
char *peek_msg;
|
||||
char *peek_msg_mem;
|
||||
size_t peek_len;
|
||||
HANDLE port;
|
||||
};
|
||||
|
||||
struct header
|
||||
@@ -167,10 +169,36 @@ struct authinfo
|
||||
BOOL finished; /* finished authenticating */
|
||||
};
|
||||
|
||||
struct queue
|
||||
{
|
||||
SRWLOCK lock;
|
||||
struct list queued_tasks;
|
||||
BOOL callback_running;
|
||||
};
|
||||
|
||||
enum request_flags
|
||||
{
|
||||
REQUEST_FLAG_WEBSOCKET_UPGRADE = 0x01,
|
||||
};
|
||||
|
||||
enum request_response_state
|
||||
{
|
||||
REQUEST_RESPONSE_STATE_NONE,
|
||||
REQUEST_RESPONSE_STATE_SENDING_REQUEST,
|
||||
REQUEST_RESPONSE_STATE_READ_RESPONSE_QUEUED,
|
||||
REQUEST_RESPONSE_STATE_REQUEST_SENT,
|
||||
REQUEST_RESPONSE_STATE_READ_RESPONSE_QUEUED_REQUEST_SENT,
|
||||
REQUEST_RESPONSE_STATE_REPLY_RECEIVED,
|
||||
REQUEST_RESPONSE_STATE_READ_RESPONSE_QUEUED_REPLY_RECEIVED,
|
||||
REQUEST_RESPONSE_RECURSIVE_REQUEST,
|
||||
REQUEST_RESPONSE_STATE_RESPONSE_RECEIVED,
|
||||
};
|
||||
|
||||
struct request
|
||||
{
|
||||
struct object_header hdr;
|
||||
struct connect *connect;
|
||||
enum request_flags flags;
|
||||
WCHAR *verb;
|
||||
WCHAR *path;
|
||||
WCHAR *version;
|
||||
@@ -189,6 +217,8 @@ struct request
|
||||
int send_timeout;
|
||||
int receive_timeout;
|
||||
int receive_response_timeout;
|
||||
DWORD max_redirects;
|
||||
DWORD redirect_count; /* total number of redirects during this request */
|
||||
WCHAR *status_text;
|
||||
DWORD content_length; /* total number of bytes to be read */
|
||||
DWORD content_read; /* bytes read so far */
|
||||
@@ -204,30 +234,112 @@ struct request
|
||||
struct authinfo *proxy_authinfo;
|
||||
HANDLE task_wait;
|
||||
HANDLE task_cancel;
|
||||
struct queue queue;
|
||||
#ifdef __REACTOS__
|
||||
HANDLE task_thread;
|
||||
#else
|
||||
BOOL task_proc_running;
|
||||
#endif
|
||||
struct list task_queue;
|
||||
CRITICAL_SECTION task_cs;
|
||||
struct
|
||||
{
|
||||
WCHAR *username;
|
||||
WCHAR *password;
|
||||
} creds[TARGET_MAX][SCHEME_MAX];
|
||||
unsigned int websocket_receive_buffer_size;
|
||||
unsigned int websocket_send_buffer_size, websocket_set_send_buffer_size;
|
||||
int read_reply_len;
|
||||
DWORD read_reply_status;
|
||||
enum request_response_state state;
|
||||
};
|
||||
|
||||
enum socket_state
|
||||
{
|
||||
SOCKET_STATE_OPEN = 0,
|
||||
SOCKET_STATE_SHUTDOWN = 1,
|
||||
SOCKET_STATE_CLOSED = 2,
|
||||
};
|
||||
|
||||
/* rfc6455 */
|
||||
enum socket_opcode
|
||||
{
|
||||
SOCKET_OPCODE_CONTINUE = 0x00,
|
||||
SOCKET_OPCODE_TEXT = 0x01,
|
||||
SOCKET_OPCODE_BINARY = 0x02,
|
||||
SOCKET_OPCODE_RESERVED3 = 0x03,
|
||||
SOCKET_OPCODE_RESERVED4 = 0x04,
|
||||
SOCKET_OPCODE_RESERVED5 = 0x05,
|
||||
SOCKET_OPCODE_RESERVED6 = 0x06,
|
||||
SOCKET_OPCODE_RESERVED7 = 0x07,
|
||||
SOCKET_OPCODE_CLOSE = 0x08,
|
||||
SOCKET_OPCODE_PING = 0x09,
|
||||
SOCKET_OPCODE_PONG = 0x0a,
|
||||
SOCKET_OPCODE_INVALID = 0xff,
|
||||
};
|
||||
|
||||
enum fragment_type
|
||||
{
|
||||
SOCKET_FRAGMENT_NONE,
|
||||
SOCKET_FRAGMENT_BINARY,
|
||||
SOCKET_FRAGMENT_UTF8,
|
||||
};
|
||||
|
||||
struct socket
|
||||
{
|
||||
struct object_header hdr;
|
||||
struct netconn *netconn;
|
||||
int keepalive_interval;
|
||||
unsigned int send_buffer_size;
|
||||
enum socket_state state;
|
||||
struct queue send_q;
|
||||
struct queue recv_q;
|
||||
enum socket_opcode opcode;
|
||||
DWORD read_size;
|
||||
char mask[4];
|
||||
unsigned int mask_index;
|
||||
BOOL close_frame_received;
|
||||
DWORD close_frame_receive_err;
|
||||
USHORT status;
|
||||
char reason[123];
|
||||
DWORD reason_len;
|
||||
char *send_frame_buffer;
|
||||
unsigned int send_frame_buffer_size;
|
||||
unsigned int send_remaining_size;
|
||||
unsigned int bytes_in_send_frame_buffer;
|
||||
unsigned int client_buffer_offset;
|
||||
char *read_buffer;
|
||||
unsigned int bytes_in_read_buffer;
|
||||
SRWLOCK send_lock;
|
||||
volatile LONG pending_noncontrol_send;
|
||||
enum fragment_type sending_fragment_type;
|
||||
enum fragment_type receiving_fragment_type;
|
||||
BOOL last_receive_final;
|
||||
};
|
||||
|
||||
typedef void (*TASK_CALLBACK)( void *ctx, BOOL abort );
|
||||
|
||||
struct task_header
|
||||
{
|
||||
struct list entry;
|
||||
struct request *request;
|
||||
void (*proc)( struct task_header * );
|
||||
TASK_CALLBACK callback;
|
||||
struct object_header *obj;
|
||||
volatile LONG refs;
|
||||
volatile LONG completion_sent;
|
||||
};
|
||||
|
||||
struct send_callback
|
||||
{
|
||||
struct task_header task_hdr;
|
||||
DWORD status;
|
||||
void *info;
|
||||
DWORD buflen;
|
||||
union
|
||||
{
|
||||
WINHTTP_ASYNC_RESULT result;
|
||||
DWORD count;
|
||||
};
|
||||
};
|
||||
|
||||
struct send_request
|
||||
{
|
||||
struct task_header hdr;
|
||||
struct task_header task_hdr;
|
||||
WCHAR *headers;
|
||||
DWORD headers_len;
|
||||
void *optional;
|
||||
@@ -238,18 +350,18 @@ struct send_request
|
||||
|
||||
struct receive_response
|
||||
{
|
||||
struct task_header hdr;
|
||||
struct task_header task_hdr;
|
||||
};
|
||||
|
||||
struct query_data
|
||||
{
|
||||
struct task_header hdr;
|
||||
struct task_header task_hdr;
|
||||
DWORD *available;
|
||||
};
|
||||
|
||||
struct read_data
|
||||
{
|
||||
struct task_header hdr;
|
||||
struct task_header task_hdr;
|
||||
void *buffer;
|
||||
DWORD to_read;
|
||||
DWORD *read;
|
||||
@@ -257,69 +369,87 @@ struct read_data
|
||||
|
||||
struct write_data
|
||||
{
|
||||
struct task_header hdr;
|
||||
struct task_header task_hdr;
|
||||
const void *buffer;
|
||||
DWORD to_write;
|
||||
DWORD *written;
|
||||
};
|
||||
|
||||
struct object_header *addref_object( struct object_header * ) DECLSPEC_HIDDEN;
|
||||
struct object_header *grab_object( HINTERNET ) DECLSPEC_HIDDEN;
|
||||
void release_object( struct object_header * ) DECLSPEC_HIDDEN;
|
||||
HINTERNET alloc_handle( struct object_header * ) DECLSPEC_HIDDEN;
|
||||
BOOL free_handle( HINTERNET ) DECLSPEC_HIDDEN;
|
||||
|
||||
void send_callback( struct object_header *, DWORD, LPVOID, DWORD ) DECLSPEC_HIDDEN;
|
||||
void close_connection( struct request * ) DECLSPEC_HIDDEN;
|
||||
|
||||
void netconn_close( struct netconn * ) DECLSPEC_HIDDEN;
|
||||
struct netconn *netconn_create( struct hostdata *, const struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
|
||||
void netconn_unload( void ) DECLSPEC_HIDDEN;
|
||||
ULONG netconn_query_data_available( struct netconn * ) DECLSPEC_HIDDEN;
|
||||
BOOL netconn_recv( struct netconn *, void *, size_t, int, int * ) DECLSPEC_HIDDEN;
|
||||
BOOL netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int ) DECLSPEC_HIDDEN;
|
||||
BOOL netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL ) DECLSPEC_HIDDEN;
|
||||
BOOL netconn_send( struct netconn *, const void *, size_t, int * ) DECLSPEC_HIDDEN;
|
||||
DWORD netconn_set_timeout( struct netconn *, BOOL, int ) DECLSPEC_HIDDEN;
|
||||
BOOL netconn_is_alive( struct netconn * ) DECLSPEC_HIDDEN;
|
||||
const void *netconn_get_certificate( struct netconn * ) DECLSPEC_HIDDEN;
|
||||
int netconn_get_cipher_strength( struct netconn * ) DECLSPEC_HIDDEN;
|
||||
|
||||
BOOL set_cookies( struct request *, const WCHAR * ) DECLSPEC_HIDDEN;
|
||||
BOOL add_cookie_headers( struct request * ) DECLSPEC_HIDDEN;
|
||||
BOOL add_request_headers( struct request *, const WCHAR *, DWORD, DWORD ) DECLSPEC_HIDDEN;
|
||||
void destroy_cookies( struct session * ) DECLSPEC_HIDDEN;
|
||||
BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT ) DECLSPEC_HIDDEN;
|
||||
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
|
||||
|
||||
void release_host( struct hostdata * ) DECLSPEC_HIDDEN;
|
||||
BOOL process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL ) DECLSPEC_HIDDEN;
|
||||
|
||||
extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
|
||||
void release_typelib( void ) DECLSPEC_HIDDEN;
|
||||
|
||||
static inline void* __WINE_ALLOC_SIZE(2) heap_realloc_zero( LPVOID mem, SIZE_T size )
|
||||
struct socket_send
|
||||
{
|
||||
return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, size );
|
||||
}
|
||||
struct task_header task_hdr;
|
||||
WINHTTP_WEB_SOCKET_BUFFER_TYPE type;
|
||||
const void *buf;
|
||||
DWORD len;
|
||||
WSAOVERLAPPED ovr;
|
||||
BOOL complete_async;
|
||||
};
|
||||
|
||||
static inline WCHAR *strdupW( const WCHAR *src )
|
||||
struct socket_receive
|
||||
{
|
||||
WCHAR *dst;
|
||||
struct task_header task_hdr;
|
||||
void *buf;
|
||||
DWORD len;
|
||||
};
|
||||
|
||||
if (!src) return NULL;
|
||||
dst = heap_alloc( (strlenW( src ) + 1) * sizeof(WCHAR) );
|
||||
if (dst) strcpyW( dst, src );
|
||||
return dst;
|
||||
}
|
||||
struct socket_shutdown
|
||||
{
|
||||
struct task_header task_hdr;
|
||||
USHORT status;
|
||||
char reason[123];
|
||||
DWORD len;
|
||||
BOOL send_callback;
|
||||
WSAOVERLAPPED ovr;
|
||||
BOOL complete_async;
|
||||
};
|
||||
|
||||
struct object_header *addref_object( struct object_header * );
|
||||
struct object_header *grab_object( HINTERNET );
|
||||
void release_object( struct object_header * );
|
||||
HINTERNET alloc_handle( struct object_header * );
|
||||
BOOL free_handle( HINTERNET );
|
||||
|
||||
void send_callback( struct object_header *, DWORD, LPVOID, DWORD );
|
||||
void close_connection( struct request * );
|
||||
void init_queue( struct queue *queue );
|
||||
void stop_queue( struct queue * );
|
||||
|
||||
void netconn_addref( struct netconn * );
|
||||
void netconn_release( struct netconn * );
|
||||
DWORD netconn_create( struct hostdata *, const struct sockaddr_storage *, int, struct netconn ** );
|
||||
void netconn_unload( void );
|
||||
ULONG netconn_query_data_available( struct netconn * );
|
||||
DWORD netconn_recv( struct netconn *, void *, size_t, int, int * );
|
||||
DWORD netconn_resolve( WCHAR *, INTERNET_PORT, struct sockaddr_storage *, int );
|
||||
DWORD netconn_secure_connect( struct netconn *, WCHAR *, DWORD, CredHandle *, BOOL );
|
||||
DWORD netconn_send( struct netconn *, const void *, size_t, int *, WSAOVERLAPPED * );
|
||||
BOOL netconn_wait_overlapped_result( struct netconn *conn, WSAOVERLAPPED *ovr, DWORD *len );
|
||||
void netconn_cancel_io( struct netconn *conn );
|
||||
DWORD netconn_set_timeout( struct netconn *, BOOL, int );
|
||||
BOOL netconn_is_alive( struct netconn * );
|
||||
const void *netconn_get_certificate( struct netconn * );
|
||||
int netconn_get_cipher_strength( struct netconn * );
|
||||
|
||||
BOOL set_cookies( struct request *, const WCHAR * );
|
||||
DWORD add_cookie_headers( struct request * );
|
||||
DWORD add_request_headers( struct request *, const WCHAR *, DWORD, DWORD );
|
||||
void destroy_cookies( struct session * );
|
||||
BOOL set_server_for_hostname( struct connect *, const WCHAR *, INTERNET_PORT );
|
||||
void destroy_authinfo( struct authinfo * );
|
||||
|
||||
void release_host( struct hostdata * );
|
||||
DWORD process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOOL );
|
||||
|
||||
extern HRESULT WinHttpRequest_create( void ** );
|
||||
void release_typelib( void );
|
||||
|
||||
static inline WCHAR *strdupAW( const char *src )
|
||||
{
|
||||
WCHAR *dst = NULL;
|
||||
if (src)
|
||||
{
|
||||
DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
|
||||
if ((dst = heap_alloc( len * sizeof(WCHAR) )))
|
||||
int len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
|
||||
if ((dst = malloc( len * sizeof(WCHAR) )))
|
||||
MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
|
||||
}
|
||||
return dst;
|
||||
@@ -331,27 +461,14 @@ static inline char *strdupWA( const WCHAR *src )
|
||||
if (src)
|
||||
{
|
||||
int len = WideCharToMultiByte( CP_ACP, 0, src, -1, NULL, 0, NULL, NULL );
|
||||
if ((dst = heap_alloc( len )))
|
||||
if ((dst = malloc( len )))
|
||||
WideCharToMultiByte( CP_ACP, 0, src, -1, dst, len, NULL, NULL );
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
|
||||
{
|
||||
char *dst = NULL;
|
||||
if (src)
|
||||
{
|
||||
int len = WideCharToMultiByte( CP_ACP, 0, src, size, NULL, 0, NULL, NULL ) + 1;
|
||||
if ((dst = heap_alloc( len )))
|
||||
{
|
||||
WideCharToMultiByte( CP_ACP, 0, src, len, dst, size, NULL, NULL );
|
||||
dst[len - 1] = 0;
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
extern HINSTANCE winhttp_instance;
|
||||
|
||||
extern HINSTANCE winhttp_instance DECLSPEC_HIDDEN;
|
||||
#define MIN_WEBSOCKET_SEND_BUFFER_SIZE 16
|
||||
|
||||
#endif /* _WINE_WINHTTP_PRIVATE_H_ */
|
||||
|
||||
@@ -213,7 +213,7 @@ dll/win32/windowscodecs # Synced to Wine-10.0
|
||||
dll/win32/windowscodecsext # Synced to Wine-10.0
|
||||
dll/win32/winemp3.acm # Synced to WineStaging-4.18
|
||||
dll/win32/wing32 # Synced to WineStaging-3.3
|
||||
dll/win32/winhttp # Synced to WineStaging-4.18
|
||||
dll/win32/winhttp # Synced to Wine-10.0
|
||||
dll/win32/wininet # Synced to WineStaging-6.0rc1
|
||||
dll/win32/winmm # Forked at Wine-20050628
|
||||
dll/win32/winmm/midimap # Forked at Wine-20050628
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
add_definitions(-DUSE_WINE_TODOS)
|
||||
remove_definitions(-D_CRT_NON_CONFORMING_SWPRINTFS)
|
||||
|
||||
list(APPEND SOURCE
|
||||
notification.c
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,80 +33,46 @@ static WCHAR username[] = {'u','s','e','r','n','a','m','e',0};
|
||||
static WCHAR password[] = {'p','a','s','s','w','o','r','d',0};
|
||||
static WCHAR about[] = {'/','s','i','t','e','/','a','b','o','u','t',0};
|
||||
static WCHAR query[] = {'?','q','u','e','r','y',0};
|
||||
static WCHAR escape[] = {' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_','`','{','|','}','~',0};
|
||||
static WCHAR escape[] = {' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>',
|
||||
'?','@','[','\\',']','^','_','`','{','|','}','~',0};
|
||||
static WCHAR escape2[] = {'\r',0x1f,' ','\n',0x7f,'\r','\n',0};
|
||||
static WCHAR escape3[] = {'?','t','e','x','t','=',0xfb00,0};
|
||||
static WCHAR escape4[] = {'/','t','e','x','t','=',0xfb00,0};
|
||||
|
||||
static const WCHAR url1[] =
|
||||
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
|
||||
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
|
||||
static const WCHAR url2[] = {'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':',0};
|
||||
static const WCHAR url3[] =
|
||||
{'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
|
||||
static const WCHAR url4[] = {'h','t','t','p',':','/','/',0};
|
||||
static const WCHAR url5[] =
|
||||
{'f','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
|
||||
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','8','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
|
||||
static const WCHAR url6[] =
|
||||
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
|
||||
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','4','2','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
|
||||
static const WCHAR url7[] =
|
||||
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
|
||||
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t',
|
||||
'%','2','0','!','%','2','2','%','2','3','$','%','2','5','&','\'','(',')','*','+',',','-','.','/',':',';','%','3','C','=','%','3','E','?','@','%',
|
||||
'5','B','%','5','C','%','5','D','%','5','E','_','%','6','0','%','7','B','%','7','C','%','7','D','%','7','E',0};
|
||||
static const WCHAR url8[] =
|
||||
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
|
||||
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
|
||||
static const WCHAR url9[] =
|
||||
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
|
||||
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','8','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
|
||||
static const WCHAR url10[] =
|
||||
{'h','t','t','p','s',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
|
||||
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','4','4','3','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
|
||||
static const WCHAR url11[] =
|
||||
{'h','t','t','p',':','/','/','e','x','a','m','p','l','e','.','n','e','t','/','p','a','t','h','?','v','a','r','1','=','e','x','a','m','p','l','e','@','e','x','a','m','p','l','e','.','c','o','m','&','v','a','r','2','=','x','&','v','a','r','3','=','y', 0};
|
||||
static const WCHAR url12[] =
|
||||
{'h','t','t','p','s',':','/','/','t','o','o','l','s','.','g','o','o','g','l','e','.','c','o','m','/','s','e','r','v','i','c','e','/','u','p','d','a','t','e','2','?','w','=','3',':','B','x','D','H','o','W','y','8','e','z','M',0};
|
||||
static const WCHAR url13[] =
|
||||
{'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o',' ','g','/','p','a','t','h',' ','w','i','t','h',' ','s','p','a','c','e','s',0};
|
||||
static const WCHAR url14[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','t','e','s','t',0};
|
||||
static const WCHAR url15[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':','6','5','5','3','6',0};
|
||||
static const WCHAR url16[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':','0',0};
|
||||
static const WCHAR url17[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':',0};
|
||||
static const WCHAR url18[] =
|
||||
{'h','t','t','p',':','/','/','%','0','D','%','1','F','%','2','0','%','0','A','%','7','F','%','0','D','%','0','A',0};
|
||||
static const WCHAR url19[] =
|
||||
{'h','t','t','p',':','/','/','?','t','e','x','t','=',0xfb00,0};
|
||||
static const WCHAR url20[] =
|
||||
{'h','t','t','p',':','/','/','/','t','e','x','t','=',0xfb00,0};
|
||||
static const WCHAR url21[] =
|
||||
{'h','t','t','p','s',':','/','/','n','b','a','2','k','1','9','-','w','s','.','2','k','s','p','o','r','t','s','.','c','o','m',':','1','9','1','3','3',
|
||||
'/','n','b','a','/','v','4','/','A','c','c','o','u','n','t','s','/','g','e','t','_','a','c','c','o','u','n','t','?','x','=','3','7','8','9','5','2',
|
||||
'6','7','7','5','2','6','5','6','6','3','8','7','6',0};
|
||||
static const WCHAR url1[] = L"http://username:[email protected]/site/about?query";
|
||||
static const WCHAR url2[] = L"http://username:";
|
||||
static const WCHAR url3[] = L"http://www.winehq.org/site/about?query";
|
||||
static const WCHAR url4[] = L"http://";
|
||||
static const WCHAR url5[] = L"ftp://username:[email protected]:80/site/about?query";
|
||||
static const WCHAR url6[] = L"http://username:[email protected]:42/site/about?query";
|
||||
static const WCHAR url7[] = L"http://username:[email protected]/site/about%20!%22%23$%25&'()"
|
||||
"*+,-./:;%3C=%3E?@%5B%5C%5D%5E_%60%7B%7C%7D%7E";
|
||||
static const WCHAR url8[] = L"http://username:[email protected]:0/site/about?query";
|
||||
static const WCHAR url9[] = L"http://username:[email protected]:80/site/about?query";
|
||||
static const WCHAR url10[] = L"https://username:[email protected]:443/site/about?query";
|
||||
static const WCHAR url11[] = L"http://example.net/[email protected]&var2=x&var3=y";
|
||||
static const WCHAR url12[] = L"https://tools.google.com/service/update2?w=3:BxDHoWy8ezM";
|
||||
static const WCHAR url13[] = L"http://winehq.o g/path with spaces";
|
||||
static const WCHAR url14[] = L"http://www.winehq.org/test";
|
||||
static const WCHAR url15[] = L"http://winehq.org:65536";
|
||||
static const WCHAR url16[] = L"http://winehq.org:0";
|
||||
static const WCHAR url17[] = L"http://winehq.org:";
|
||||
static const WCHAR url18[] = L"http://%0D%1F%20%0A%7F%0D%0A";
|
||||
static const WCHAR url19[] = L"http://?text=\xfb00";
|
||||
static const WCHAR url20[] = L"http:///text=\xfb00";
|
||||
static const WCHAR url21[] = L"https://nba2k19-ws.2ksports.com:19133/nba/v4/Accounts/get_account?x=3789526775265663876";
|
||||
static const WCHAR url22[] = L"http://winehq.org:/";
|
||||
|
||||
static const WCHAR url_k1[] =
|
||||
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
|
||||
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
|
||||
static const WCHAR url_k2[] =
|
||||
{'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
|
||||
static const WCHAR url_k3[] =
|
||||
{'h','t','t','p','s',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','p','o','s','t','?',0};
|
||||
static const WCHAR url_k4[] =
|
||||
{'H','T','T','P',':','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
|
||||
static const WCHAR url_k5[] =
|
||||
{'h','t','t','p',':','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
|
||||
static const WCHAR url_k6[] =
|
||||
{'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
|
||||
static const WCHAR url_k7[] =
|
||||
{'w','w','w',0};
|
||||
static const WCHAR url_k8[] =
|
||||
{'h','t','t','p',0};
|
||||
static const WCHAR url_k9[] =
|
||||
{'h','t','t','p',':','/','/','w','i','n','e','h','q','?',0};
|
||||
static const WCHAR url_k10[] =
|
||||
{'h','t','t','p',':','/','/','w','i','n','e','h','q','/','p','o','s','t',';','a',0};
|
||||
static const WCHAR url_k1[] = L"http://username:[email protected]/site/about";
|
||||
static const WCHAR url_k2[] = L"http://www.winehq.org";
|
||||
static const WCHAR url_k3[] = L"https://www.winehq.org/post?";
|
||||
static const WCHAR url_k4[] = L"HTTP:www.winehq.org";
|
||||
static const WCHAR url_k5[] = L"http:/www.winehq.org";
|
||||
static const WCHAR url_k6[] = L"www.winehq.org";
|
||||
static const WCHAR url_k7[] = L"www";
|
||||
static const WCHAR url_k8[] = L"http";
|
||||
static const WCHAR url_k9[] = L"http://winehq?";
|
||||
static const WCHAR url_k10[] = L"http://winehq/post;a";
|
||||
|
||||
static void fill_url_components( URL_COMPONENTS *uc )
|
||||
{
|
||||
@@ -139,31 +105,31 @@ static void WinHttpCreateUrl_test( void )
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCreateUrl( NULL, 0, NULL, &len );
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
|
||||
ok( len == ~0u, "expected len ~0u got %u\n", len );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", GetLastError() );
|
||||
ok( len == ~0u, "expected len ~0u got %lu\n", len );
|
||||
|
||||
/* zero'ed components */
|
||||
memset( &uc, 0, sizeof(URL_COMPONENTS) );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
|
||||
ok( len == ~0u, "expected len ~0u got %u\n", len );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", GetLastError() );
|
||||
ok( len == ~0u, "expected len ~0u got %lu\n", len );
|
||||
|
||||
/* valid components, NULL url, NULL length */
|
||||
fill_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCreateUrl( &uc, 0, NULL, NULL );
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", GetLastError() );
|
||||
|
||||
/* valid components, NULL url, insufficient length */
|
||||
len = 0;
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCreateUrl( &uc, 0, NULL, &len );
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER got %u\n", GetLastError() );
|
||||
ok( len == 57, "expected len 57 got %u\n", len );
|
||||
ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER got %lu\n", GetLastError() );
|
||||
ok( len == 57, "expected len 57 got %lu\n", len );
|
||||
|
||||
/* valid components, NULL url, sufficient length */
|
||||
SetLastError( 0xdeadbeef );
|
||||
@@ -172,8 +138,8 @@ static void WinHttpCreateUrl_test( void )
|
||||
err = GetLastError();
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( err == ERROR_INVALID_PARAMETER || broken(err == ERROR_INSUFFICIENT_BUFFER) /* < win7 */,
|
||||
"expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
|
||||
ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %u\n", len );
|
||||
"expected ERROR_INVALID_PARAMETER got %lu\n", GetLastError() );
|
||||
ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %lu\n", len );
|
||||
|
||||
/* correct size, NULL url */
|
||||
fill_url_components( &uc );
|
||||
@@ -182,8 +148,8 @@ static void WinHttpCreateUrl_test( void )
|
||||
err = GetLastError();
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( err == ERROR_INVALID_PARAMETER || broken(err == ERROR_INSUFFICIENT_BUFFER) /* < win7 */,
|
||||
"expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
|
||||
ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %u\n", len );
|
||||
"expected ERROR_INVALID_PARAMETER got %lu\n", GetLastError() );
|
||||
ok( len == 256 || broken(len == 57) /* < win7 */, "expected len 256 got %lu\n", len );
|
||||
|
||||
/* valid components, allocated url, short length */
|
||||
SetLastError( 0xdeadbeef );
|
||||
@@ -192,8 +158,8 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 2;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER got %u\n", GetLastError() );
|
||||
ok( len == 57, "expected len 57 got %u\n", len );
|
||||
ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER got %lu\n", GetLastError() );
|
||||
ok( len == 57, "expected len 57 got %lu\n", len );
|
||||
|
||||
/* allocated url, NULL scheme */
|
||||
SetLastError( 0xdeadbeef );
|
||||
@@ -203,8 +169,8 @@ static void WinHttpCreateUrl_test( void )
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( GetLastError() == ERROR_SUCCESS || broken(GetLastError() == 0xdeadbeef) /* < win7 */,
|
||||
"expected ERROR_SUCCESS got %u\n", GetLastError() );
|
||||
ok( len == 56, "expected len 56 got %u\n", len );
|
||||
"expected ERROR_SUCCESS got %lu\n", GetLastError() );
|
||||
ok( len == 56, "expected len 56 got %lu\n", len );
|
||||
ok( !lstrcmpW( url, url1 ), "url doesn't match\n" );
|
||||
|
||||
/* allocated url, 0 scheme */
|
||||
@@ -214,7 +180,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == 56, "expected len 56 got %u\n", len );
|
||||
ok( len == 56, "expected len 56 got %lu\n", len );
|
||||
|
||||
/* valid components, allocated url */
|
||||
fill_url_components( &uc );
|
||||
@@ -222,7 +188,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == 56, "expected len 56 got %d\n", len );
|
||||
ok( len == 56, "expected len 56 got %lu\n", len );
|
||||
ok( !lstrcmpW( url, url1 ), "url doesn't match\n" );
|
||||
|
||||
/* valid username, NULL password */
|
||||
@@ -240,7 +206,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == 56, "expected len 56 got %u\n", len );
|
||||
ok( len == 56, "expected len 56 got %lu\n", len );
|
||||
ok( !lstrcmpW( url, url2 ), "url doesn't match\n" );
|
||||
|
||||
/* valid password, NULL username */
|
||||
@@ -251,7 +217,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %u\n", GetLastError() );
|
||||
ok( GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got %lu\n", GetLastError() );
|
||||
|
||||
/* valid password, empty username */
|
||||
fill_url_components( &uc );
|
||||
@@ -269,7 +235,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == 38, "expected len 38 got %u\n", len );
|
||||
ok( len == 38, "expected len 38 got %lu\n", len );
|
||||
ok( !lstrcmpW( url, url3 ), "url doesn't match\n" );
|
||||
|
||||
/* empty username, empty password */
|
||||
@@ -280,7 +246,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == 56, "expected len 56 got %u\n", len );
|
||||
ok( len == 56, "expected len 56 got %lu\n", len );
|
||||
ok( !lstrcmpW( url, url4 ), "url doesn't match\n" );
|
||||
|
||||
/* nScheme has lower precedence than lpszScheme */
|
||||
@@ -291,7 +257,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == lstrlenW( url5 ), "expected len %d got %u\n", lstrlenW( url5 ) + 1, len );
|
||||
ok( len == lstrlenW( url5 ), "expected len %d got %lu\n", lstrlenW( url5 ) + 1, len );
|
||||
ok( !lstrcmpW( url, url5 ), "url doesn't match\n" );
|
||||
|
||||
/* non-standard port */
|
||||
@@ -302,7 +268,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == 59, "expected len 59 got %u\n", len );
|
||||
ok( len == 59, "expected len 59 got %lu\n", len );
|
||||
ok( !lstrcmpW( url, url6 ), "url doesn't match\n" );
|
||||
|
||||
/* escape extra info */
|
||||
@@ -313,7 +279,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, ICU_ESCAPE, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == 113, "expected len 113 got %u\n", len );
|
||||
ok( len == 113, "expected len 113 got %lu\n", len );
|
||||
ok( !lstrcmpW( url, url7 ), "url doesn't match %s\n", wine_dbgstr_w(url) );
|
||||
|
||||
/* escape extra info */
|
||||
@@ -325,7 +291,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, ICU_ESCAPE, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == lstrlenW(url18), "expected len %u got %u\n", lstrlenW(url18), len );
|
||||
ok( len == lstrlenW(url18), "expected len %u got %lu\n", lstrlenW(url18), len );
|
||||
ok( !lstrcmpW( url, url18 ), "url doesn't match\n" );
|
||||
|
||||
/* extra info with Unicode characters */
|
||||
@@ -338,8 +304,8 @@ static void WinHttpCreateUrl_test( void )
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCreateUrl( &uc, ICU_ESCAPE, url, &len );
|
||||
err = GetLastError();
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( err == ERROR_INVALID_PARAMETER, "got %u\n", err );
|
||||
ok( !ret || GetACP() == CP_UTF8, "expected failure\n" );
|
||||
ok( err == ERROR_INVALID_PARAMETER || (!err && GetACP() == CP_UTF8), "got %lu\n", err );
|
||||
|
||||
/* extra info with Unicode characters, no ICU_ESCAPE */
|
||||
memset( &uc, 0, sizeof(uc) );
|
||||
@@ -352,7 +318,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
ok( ret || broken(!ret) /* < win7 */, "expected success\n" );
|
||||
if (ret)
|
||||
{
|
||||
ok( len == lstrlenW(url19), "expected len %u got %u\n", lstrlenW(url19), len );
|
||||
ok( len == lstrlenW(url19), "expected len %u got %lu\n", lstrlenW(url19), len );
|
||||
ok( !lstrcmpW( url, url19 ), "url doesn't match %s\n", wine_dbgstr_w(url) );
|
||||
}
|
||||
|
||||
@@ -365,7 +331,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, ICU_ESCAPE, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == lstrlenW(url18), "expected len %u got %u\n", lstrlenW(url18), len );
|
||||
ok( len == lstrlenW(url18), "expected len %u got %lu\n", lstrlenW(url18), len );
|
||||
ok( !lstrcmpW( url, url18 ), "url doesn't match\n" );
|
||||
|
||||
/* path with Unicode characters */
|
||||
@@ -378,8 +344,8 @@ static void WinHttpCreateUrl_test( void )
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCreateUrl( &uc, ICU_ESCAPE, url, &len );
|
||||
err = GetLastError();
|
||||
ok( !ret, "expected failure\n" );
|
||||
ok( err == ERROR_INVALID_PARAMETER, "got %u\n", err );
|
||||
ok( !ret || GetACP() == CP_UTF8, "expected failure\n" );
|
||||
ok( err == ERROR_INVALID_PARAMETER || (!err && GetACP() == CP_UTF8), "got %lu\n", err );
|
||||
|
||||
/* path with Unicode characters, no ICU_ESCAPE */
|
||||
memset( &uc, 0, sizeof(uc) );
|
||||
@@ -392,7 +358,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
ok( ret || broken(!ret) /* < win7 */, "expected success\n" );
|
||||
if (ret)
|
||||
{
|
||||
ok( len == lstrlenW(url20), "expected len %u got %u\n", lstrlenW(url20), len );
|
||||
ok( len == lstrlenW(url20), "expected len %u got %lu\n", lstrlenW(url20), len );
|
||||
ok( !lstrcmpW( url, url20 ), "url doesn't match %s\n", wine_dbgstr_w(url) );
|
||||
}
|
||||
|
||||
@@ -406,7 +372,7 @@ static void WinHttpCreateUrl_test( void )
|
||||
len = 256;
|
||||
ret = WinHttpCreateUrl( &uc, 0, url, &len );
|
||||
ok( ret, "expected success\n" );
|
||||
ok( len == 58, "expected len 58 got %u\n", len );
|
||||
ok( len == 58, "expected len 58 got %lu\n", len );
|
||||
ok( !lstrcmpW( url, url8 ), "url doesn't match\n" );
|
||||
|
||||
HeapFree( GetProcessHeap(), 0, url );
|
||||
@@ -427,10 +393,6 @@ static void reset_url_components( URL_COMPONENTS *uc )
|
||||
|
||||
static void WinHttpCrackUrl_test( void )
|
||||
{
|
||||
static const WCHAR hostnameW[] =
|
||||
{'w','i','n','e','h','q','.','o',' ','g',0};
|
||||
static const WCHAR pathW[] =
|
||||
{'/','p','a','t','h','%','2','0','w','i','t','h','%','2','0','s','p','a','c','e','s',0};
|
||||
URL_COMPONENTSW uc;
|
||||
WCHAR scheme[20], user[20], pass[20], host[40], path[80], extra[40];
|
||||
DWORD error;
|
||||
@@ -456,21 +418,21 @@ static void WinHttpCrackUrl_test( void )
|
||||
uc.dwExtraInfoLength = 20;
|
||||
|
||||
ret = WinHttpCrackUrl( url1, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme: %u\n", uc.nScheme );
|
||||
ok( !memcmp( uc.lpszScheme, http, sizeof(http) ), "unexpected scheme: %s\n", wine_dbgstr_w(uc.lpszScheme) );
|
||||
ok( uc.dwSchemeLength == 4, "unexpected scheme length: %u\n", uc.dwSchemeLength );
|
||||
ok( uc.dwSchemeLength == 4, "unexpected scheme length: %lu\n", uc.dwSchemeLength );
|
||||
ok( !memcmp( uc.lpszUserName, username, sizeof(username) ), "unexpected username: %s\n", wine_dbgstr_w(uc.lpszUserName) );
|
||||
ok( uc.dwUserNameLength == 8, "unexpected username length: %u\n", uc.dwUserNameLength );
|
||||
ok( uc.dwUserNameLength == 8, "unexpected username length: %lu\n", uc.dwUserNameLength );
|
||||
ok( !memcmp( uc.lpszPassword, password, sizeof(password) ), "unexpected password: %s\n", wine_dbgstr_w(uc.lpszPassword) );
|
||||
ok( uc.dwPasswordLength == 8, "unexpected password length: %u\n", uc.dwPasswordLength );
|
||||
ok( uc.dwPasswordLength == 8, "unexpected password length: %lu\n", uc.dwPasswordLength );
|
||||
ok( !memcmp( uc.lpszHostName, winehq, sizeof(winehq) ), "unexpected hostname: %s\n", wine_dbgstr_w(uc.lpszHostName) );
|
||||
ok( uc.dwHostNameLength == 14, "unexpected hostname length: %u\n", uc.dwHostNameLength );
|
||||
ok( uc.dwHostNameLength == 14, "unexpected hostname length: %lu\n", uc.dwHostNameLength );
|
||||
ok( uc.nPort == 80, "unexpected port: %u\n", uc.nPort );
|
||||
ok( !memcmp( uc.lpszUrlPath, about, sizeof(about) ), "unexpected path: %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
|
||||
ok( uc.dwUrlPathLength == 11, "unexpected path length: %u\n", uc.dwUrlPathLength );
|
||||
ok( uc.dwUrlPathLength == 11, "unexpected path length: %lu\n", uc.dwUrlPathLength );
|
||||
ok( !memcmp( uc.lpszExtraInfo, query, sizeof(query) ), "unexpected extra info: %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
|
||||
ok( uc.dwExtraInfoLength == 6, "unexpected extra info length: %u\n", uc.dwExtraInfoLength );
|
||||
ok( uc.dwExtraInfoLength == 6, "unexpected extra info length: %lu\n", uc.dwExtraInfoLength );
|
||||
|
||||
/* buffers of insufficient length */
|
||||
uc.dwSchemeLength = 1;
|
||||
@@ -480,19 +442,19 @@ static void WinHttpCrackUrl_test( void )
|
||||
ret = WinHttpCrackUrl( url1, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_INSUFFICIENT_BUFFER, "got %u, expected ERROR_INSUFFICIENT_BUFFER\n", error );
|
||||
ok( uc.dwSchemeLength == 5, "unexpected scheme length: %u\n", uc.dwSchemeLength );
|
||||
ok( uc.dwHostNameLength == 15, "unexpected hostname length: %u\n", uc.dwHostNameLength );
|
||||
ok( uc.dwUrlPathLength == 11, "unexpected path length: %u\n", uc.dwUrlPathLength );
|
||||
ok( error == ERROR_INSUFFICIENT_BUFFER, "got %lu, expected ERROR_INSUFFICIENT_BUFFER\n", error );
|
||||
ok( uc.dwSchemeLength == 5, "unexpected scheme length: %lu\n", uc.dwSchemeLength );
|
||||
ok( uc.dwHostNameLength == 15, "unexpected hostname length: %lu\n", uc.dwHostNameLength );
|
||||
ok( uc.dwUrlPathLength == 11, "unexpected path length: %lu\n", uc.dwUrlPathLength );
|
||||
|
||||
/* no buffers */
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( url_k1, 0, 0, &uc);
|
||||
error = GetLastError();
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", error );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", error );
|
||||
ok( error == ERROR_SUCCESS || broken(error == ERROR_INVALID_PARAMETER) /* < win7 */,
|
||||
"got %u, expected ERROR_SUCCESS\n", error );
|
||||
"got %lu, expected ERROR_SUCCESS\n", error );
|
||||
ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" );
|
||||
ok( uc.lpszScheme == url_k1,"unexpected scheme\n" );
|
||||
ok( uc.dwSchemeLength == 4, "unexpected scheme length\n" );
|
||||
@@ -512,7 +474,7 @@ static void WinHttpCrackUrl_test( void )
|
||||
uc.dwSchemeLength = uc.dwHostNameLength = uc.dwUserNameLength = 1;
|
||||
uc.dwPasswordLength = uc.dwUrlPathLength = uc.dwExtraInfoLength = 1;
|
||||
ret = WinHttpCrackUrl( url_k2, 0, 0,&uc);
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" );
|
||||
ok( uc.lpszScheme == url_k2, "unexpected scheme\n" );
|
||||
ok( uc.dwSchemeLength == 4, "unexpected scheme length\n" );
|
||||
@@ -530,7 +492,7 @@ static void WinHttpCrackUrl_test( void )
|
||||
|
||||
reset_url_components( &uc );
|
||||
ret = WinHttpCrackUrl( url_k3, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.nScheme == INTERNET_SCHEME_HTTPS, "unexpected scheme\n" );
|
||||
ok( uc.lpszScheme == url_k3, "unexpected scheme\n" );
|
||||
ok( uc.dwSchemeLength == 5, "unexpected scheme length\n" );
|
||||
@@ -552,80 +514,80 @@ static void WinHttpCrackUrl_test( void )
|
||||
ret = WinHttpCrackUrl( url_k4, 0, 0, &uc );
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
error = GetLastError();
|
||||
ok( error == ERROR_WINHTTP_INVALID_URL, "got %u\n", error );
|
||||
ok( error == ERROR_WINHTTP_INVALID_URL, "got %lu\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( url_k5, 0, 0, &uc );
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
error = GetLastError();
|
||||
ok( error == ERROR_WINHTTP_INVALID_URL, "got %u\n", error );
|
||||
ok( error == ERROR_WINHTTP_INVALID_URL, "got %lu\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( url_k6, 0, 0, &uc );
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
error = GetLastError();
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u\n", error );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %lu\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( url_k7, 0, 0, &uc );
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
error = GetLastError();
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u\n", error );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %lu\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( url_k8, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u\n", error );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %lu\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
ret = WinHttpCrackUrl( url_k9, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.lpszUrlPath == url_k9 + 14 || broken(uc.lpszUrlPath == url_k9 + 13) /* win8 */,
|
||||
"unexpected path: %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
|
||||
ok( uc.dwUrlPathLength == 0, "unexpected path length: %u\n", uc.dwUrlPathLength );
|
||||
ok( uc.dwUrlPathLength == 0, "unexpected path length: %lu\n", uc.dwUrlPathLength );
|
||||
ok( uc.lpszExtraInfo == url_k9 + 14 || broken(uc.lpszExtraInfo == url_k9 + 13) /* win8 */,
|
||||
"unexpected extra info: %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
|
||||
ok( uc.dwExtraInfoLength == 0 || broken(uc.dwExtraInfoLength == 1) /* win8 */,
|
||||
"unexpected extra info length: %u\n", uc.dwExtraInfoLength );
|
||||
"unexpected extra info length: %lu\n", uc.dwExtraInfoLength );
|
||||
|
||||
reset_url_components( &uc );
|
||||
ret = WinHttpCrackUrl( url_k10, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.lpszUrlPath == url_k10 + 13, "unexpected path: %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
|
||||
ok( uc.dwUrlPathLength == 7, "unexpected path length: %u\n", uc.dwUrlPathLength );
|
||||
ok( uc.dwUrlPathLength == 7, "unexpected path length: %lu\n", uc.dwUrlPathLength );
|
||||
ok( uc.lpszExtraInfo == url_k10 + 20, "unexpected extra info: %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
|
||||
ok( uc.dwExtraInfoLength == 0, "unexpected extra info length: %u\n", uc.dwExtraInfoLength );
|
||||
ok( uc.dwExtraInfoLength == 0, "unexpected extra info length: %lu\n", uc.dwExtraInfoLength );
|
||||
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( url4, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_WINHTTP_INVALID_URL, "got %u\n", error );
|
||||
ok( error == ERROR_WINHTTP_INVALID_URL, "got %lu\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( empty, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u\n", error );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %lu\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( url1, 0, 0, NULL );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( NULL, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
|
||||
/* decoding without buffers */
|
||||
reset_url_components( &uc );
|
||||
@@ -633,7 +595,7 @@ static void WinHttpCrackUrl_test( void )
|
||||
ret = WinHttpCrackUrl( url7, 0, ICU_DECODE, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u, expected ERROR_INVALID_PARAMETER\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu, expected ERROR_INVALID_PARAMETER\n", error );
|
||||
|
||||
/* decoding with buffers */
|
||||
uc.lpszScheme = scheme;
|
||||
@@ -652,11 +614,11 @@ static void WinHttpCrackUrl_test( void )
|
||||
path[0] = 0;
|
||||
|
||||
ret = WinHttpCrackUrl( url7, 0, ICU_DECODE, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed %u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed %lu\n", GetLastError() );
|
||||
ok( !memcmp( uc.lpszUrlPath + 11, escape, 21 * sizeof(WCHAR) ), "unexpected path\n" );
|
||||
ok( uc.dwUrlPathLength == 32, "unexpected path length %u\n", uc.dwUrlPathLength );
|
||||
ok( uc.dwUrlPathLength == 32, "unexpected path length %lu\n", uc.dwUrlPathLength );
|
||||
ok( !memcmp( uc.lpszExtraInfo, escape + 21, 12 * sizeof(WCHAR) ), "unexpected extra info\n" );
|
||||
ok( uc.dwExtraInfoLength == 12, "unexpected extra info length %u\n", uc.dwExtraInfoLength );
|
||||
ok( uc.dwExtraInfoLength == 12, "unexpected extra info length %lu\n", uc.dwExtraInfoLength );
|
||||
|
||||
/* Urls with specified port numbers */
|
||||
/* decoding with buffers */
|
||||
@@ -676,25 +638,25 @@ static void WinHttpCrackUrl_test( void )
|
||||
path[0] = 0;
|
||||
|
||||
ret = WinHttpCrackUrl( url6, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( !memcmp( uc.lpszHostName, winehq, sizeof(winehq) ), "unexpected host name: %s\n", wine_dbgstr_w(uc.lpszHostName) );
|
||||
ok( uc.dwHostNameLength == 14, "unexpected host name length: %d\n", uc.dwHostNameLength );
|
||||
ok( uc.dwHostNameLength == 14, "unexpected host name length: %lu\n", uc.dwHostNameLength );
|
||||
ok( uc.nPort == 42, "unexpected port: %u\n", uc.nPort );
|
||||
|
||||
/* decoding without buffers */
|
||||
reset_url_components( &uc );
|
||||
ret = WinHttpCrackUrl( url8, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.nPort == 0, "unexpected port: %u\n", uc.nPort );
|
||||
|
||||
reset_url_components( &uc );
|
||||
ret = WinHttpCrackUrl( url9, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.nPort == 80, "unexpected port: %u\n", uc.nPort );
|
||||
|
||||
reset_url_components( &uc );
|
||||
ret = WinHttpCrackUrl( url10, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.nPort == 443, "unexpected port: %u\n", uc.nPort );
|
||||
|
||||
reset_url_components( &uc );
|
||||
@@ -702,18 +664,18 @@ static void WinHttpCrackUrl_test( void )
|
||||
ret = WinHttpCrackUrl( empty, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u, expected ERROR_WINHTTP_UNRECOGNIZED_SCHEME\n", error );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %lu, expected ERROR_WINHTTP_UNRECOGNIZED_SCHEME\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( http, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %u, expected ERROR_WINHTTP_UNRECOGNIZED_SCHEME\n", error );
|
||||
ok( error == ERROR_WINHTTP_UNRECOGNIZED_SCHEME, "got %lu, expected ERROR_WINHTTP_UNRECOGNIZED_SCHEME\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
ret = WinHttpCrackUrl( url11, 0, 0, &uc);
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme\n" );
|
||||
ok( uc.lpszScheme == url11,"unexpected scheme\n" );
|
||||
ok( uc.dwSchemeLength == 4, "unexpected scheme length\n" );
|
||||
@@ -741,7 +703,7 @@ static void WinHttpCrackUrl_test( void )
|
||||
uc.dwExtraInfoLength = 0;
|
||||
uc.nPort = 0;
|
||||
ret = WinHttpCrackUrl( url12, 0, ICU_DECODE, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
|
||||
uc.lpszScheme = scheme;
|
||||
uc.dwSchemeLength = 20;
|
||||
@@ -757,10 +719,10 @@ static void WinHttpCrackUrl_test( void )
|
||||
uc.dwExtraInfoLength = 0;
|
||||
uc.nPort = 0;
|
||||
ret = WinHttpCrackUrl( url13, 0, ICU_ESCAPE|ICU_DECODE, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( !lstrcmpW( uc.lpszHostName, hostnameW ), "unexpected host name\n" );
|
||||
ok( !lstrcmpW( uc.lpszUrlPath, pathW ), "unexpected path\n" );
|
||||
ok( uc.dwUrlPathLength == lstrlenW(pathW), "got %u\n", uc.dwUrlPathLength );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( !lstrcmpW( uc.lpszHostName, L"winehq.o g" ), "unexpected host name\n" );
|
||||
ok( !lstrcmpW( uc.lpszUrlPath, L"/path%20with%20spaces" ), "unexpected path\n" );
|
||||
ok( uc.dwUrlPathLength == lstrlenW(L"/path%20with%20spaces"), "got %lu\n", uc.dwUrlPathLength );
|
||||
|
||||
uc.dwStructSize = sizeof(uc);
|
||||
uc.lpszScheme = NULL;
|
||||
@@ -778,21 +740,21 @@ static void WinHttpCrackUrl_test( void )
|
||||
uc.lpszExtraInfo = NULL;
|
||||
uc.dwExtraInfoLength = ~0u;
|
||||
ret = WinHttpCrackUrl( url14, 0, 0, &uc );
|
||||
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
|
||||
ok( ret, "WinHttpCrackUrl failed le = %lu\n", GetLastError() );
|
||||
ok( !uc.lpszScheme, "unexpected scheme %s\n", wine_dbgstr_w(uc.lpszScheme) );
|
||||
ok( !uc.dwSchemeLength, "unexpected length %u\n", uc.dwSchemeLength );
|
||||
ok( !uc.dwSchemeLength, "unexpected length %lu\n", uc.dwSchemeLength );
|
||||
ok( uc.nScheme == INTERNET_SCHEME_HTTP, "unexpected scheme %u\n", uc.nScheme );
|
||||
ok( !lstrcmpW( uc.lpszHostName, url14 + 7 ), "unexpected hostname %s\n", wine_dbgstr_w(uc.lpszHostName) );
|
||||
ok( uc.dwHostNameLength == 14, "unexpected length %u\n", uc.dwHostNameLength );
|
||||
ok( uc.dwHostNameLength == 14, "unexpected length %lu\n", uc.dwHostNameLength );
|
||||
ok( uc.nPort == 80, "unexpected port %u\n", uc.nPort );
|
||||
ok( !uc.lpszUserName, "unexpected username\n" );
|
||||
ok( !uc.dwUserNameLength, "unexpected length %u\n", uc.dwUserNameLength );
|
||||
ok( !uc.dwUserNameLength, "unexpected length %lu\n", uc.dwUserNameLength );
|
||||
ok( !uc.lpszPassword, "unexpected password\n" );
|
||||
ok( !uc.dwPasswordLength, "unexpected length %u\n", uc.dwPasswordLength );
|
||||
ok( !uc.dwPasswordLength, "unexpected length %lu\n", uc.dwPasswordLength );
|
||||
ok( !lstrcmpW( uc.lpszUrlPath, url14 + 21 ), "unexpected path %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
|
||||
ok( uc.dwUrlPathLength == 5, "unexpected length %u\n", uc.dwUrlPathLength );
|
||||
ok( uc.dwUrlPathLength == 5, "unexpected length %lu\n", uc.dwUrlPathLength );
|
||||
ok( !uc.lpszExtraInfo[0], "unexpected extra info %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
|
||||
ok( uc.dwExtraInfoLength == 0, "unexpected length %u\n", uc.dwExtraInfoLength );
|
||||
ok( uc.dwExtraInfoLength == 0, "unexpected length %lu\n", uc.dwExtraInfoLength );
|
||||
|
||||
uc.dwStructSize = sizeof(uc);
|
||||
uc.lpszScheme = scheme;
|
||||
@@ -813,40 +775,46 @@ static void WinHttpCrackUrl_test( void )
|
||||
ret = WinHttpCrackUrl( url14, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %u\n", error );
|
||||
ok( error == ERROR_INVALID_PARAMETER, "got %lu\n", error );
|
||||
ok( !lstrcmpW( uc.lpszScheme, http ), "unexpected scheme %s\n", wine_dbgstr_w(uc.lpszScheme) );
|
||||
ok( !uc.dwSchemeLength, "unexpected length %u\n", uc.dwSchemeLength );
|
||||
ok( !uc.dwSchemeLength, "unexpected length %lu\n", uc.dwSchemeLength );
|
||||
ok( uc.nScheme == 0, "unexpected scheme %u\n", uc.nScheme );
|
||||
ok( !uc.lpszHostName, "unexpected hostname %s\n", wine_dbgstr_w(uc.lpszHostName) );
|
||||
ok( uc.dwHostNameLength == 0, "unexpected length %u\n", uc.dwHostNameLength );
|
||||
ok( uc.dwHostNameLength == 0, "unexpected length %lu\n", uc.dwHostNameLength );
|
||||
ok( uc.nPort == 0, "unexpected port %u\n", uc.nPort );
|
||||
ok( !uc.lpszUserName, "unexpected username\n" );
|
||||
ok( uc.dwUserNameLength == ~0u, "unexpected length %u\n", uc.dwUserNameLength );
|
||||
ok( uc.dwUserNameLength == ~0u, "unexpected length %lu\n", uc.dwUserNameLength );
|
||||
ok( !uc.lpszPassword, "unexpected password\n" );
|
||||
ok( uc.dwPasswordLength == ~0u, "unexpected length %u\n", uc.dwPasswordLength );
|
||||
ok( uc.dwPasswordLength == ~0u, "unexpected length %lu\n", uc.dwPasswordLength );
|
||||
ok( !uc.lpszUrlPath, "unexpected path %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
|
||||
ok( uc.dwUrlPathLength == 0, "unexpected length %u\n", uc.dwUrlPathLength );
|
||||
ok( uc.dwUrlPathLength == 0, "unexpected length %lu\n", uc.dwUrlPathLength );
|
||||
ok( !uc.lpszExtraInfo, "unexpected extra info %s\n", wine_dbgstr_w(uc.lpszExtraInfo) );
|
||||
ok( uc.dwExtraInfoLength == 0, "unexpected length %u\n", uc.dwExtraInfoLength );
|
||||
ok( uc.dwExtraInfoLength == 0, "unexpected length %lu\n", uc.dwExtraInfoLength );
|
||||
|
||||
reset_url_components( &uc );
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = WinHttpCrackUrl( url15, 0, 0, &uc );
|
||||
error = GetLastError();
|
||||
ok( !ret, "WinHttpCrackUrl succeeded\n" );
|
||||
ok( error == ERROR_WINHTTP_INVALID_URL, "got %u\n", error );
|
||||
ok( error == ERROR_WINHTTP_INVALID_URL, "got %lu\n", error );
|
||||
|
||||
reset_url_components( &uc );
|
||||
uc.nPort = 1;
|
||||
ret = WinHttpCrackUrl( url16, 0, 0, &uc );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( ret, "got %lu\n", GetLastError() );
|
||||
ok( !uc.nPort, "got %u\n", uc.nPort );
|
||||
|
||||
reset_url_components( &uc );
|
||||
uc.nPort = 1;
|
||||
ret = WinHttpCrackUrl( url17, 0, 0, &uc );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
todo_wine ok( uc.nPort == 80, "got %u\n", uc.nPort );
|
||||
ok( ret, "got %lu\n", GetLastError() );
|
||||
ok( uc.nPort == 80, "got %u\n", uc.nPort );
|
||||
|
||||
reset_url_components( &uc );
|
||||
uc.nPort = 1;
|
||||
ret = WinHttpCrackUrl( url22, 0, 0, &uc );
|
||||
ok( ret, "got %lu\n", GetLastError() );
|
||||
ok( uc.nPort == 80, "got %u\n", uc.nPort );
|
||||
|
||||
memset( &uc, 0, sizeof(uc) );
|
||||
uc.dwStructSize = sizeof(uc);
|
||||
@@ -857,9 +825,9 @@ static void WinHttpCrackUrl_test( void )
|
||||
uc.lpszUrlPath = path;
|
||||
uc.dwUrlPathLength = ARRAY_SIZE(path);
|
||||
ret = WinHttpCrackUrl( url21, 0, 0, &uc );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( ret, "got %lu\n", GetLastError() );
|
||||
ok( !lstrcmpW( uc.lpszUrlPath, url21 + 37 ), "unexpected path %s\n", wine_dbgstr_w(uc.lpszUrlPath) );
|
||||
ok( uc.dwUrlPathLength == 50, "unexpected length %u\n", uc.dwUrlPathLength );
|
||||
ok( uc.dwUrlPathLength == 50, "unexpected length %lu\n", uc.dwUrlPathLength );
|
||||
}
|
||||
|
||||
START_TEST(url)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
+433
-4
@@ -25,7 +25,12 @@
|
||||
#include <pshpack4.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WINHTTP_INTERNAL_
|
||||
#define WINHTTPAPI
|
||||
#else
|
||||
#define WINHTTPAPI DECLSPEC_IMPORT
|
||||
#endif
|
||||
|
||||
#define BOOLAPI WINHTTPAPI BOOL WINAPI
|
||||
|
||||
|
||||
@@ -46,6 +51,8 @@ typedef INTERNET_PORT *LPINTERNET_PORT;
|
||||
typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
|
||||
#define ICU_ESCAPE 0x80000000
|
||||
#define ICU_ESCAPE_AUTHORITY 0x00002000
|
||||
#define ICU_REJECT_USERPWD 0x00004000
|
||||
|
||||
/* flags for WinHttpOpen */
|
||||
#define WINHTTP_FLAG_ASYNC 0x10000000
|
||||
@@ -62,6 +69,7 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define WINHTTP_ACCESS_TYPE_DEFAULT_PROXY 0
|
||||
#define WINHTTP_ACCESS_TYPE_NO_PROXY 1
|
||||
#define WINHTTP_ACCESS_TYPE_NAMED_PROXY 3
|
||||
#define WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY 4
|
||||
|
||||
#define WINHTTP_NO_PROXY_NAME NULL
|
||||
#define WINHTTP_NO_PROXY_BYPASS NULL
|
||||
@@ -108,6 +116,7 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define WINHTTP_OPTION_URL 34
|
||||
#define WINHTTP_OPTION_SECURITY_KEY_BITNESS 36
|
||||
#define WINHTTP_OPTION_PROXY 38
|
||||
#define WINHTTP_OPTION_PROXY_RESULT_ENTRY 39
|
||||
#define WINHTTP_OPTION_USER_AGENT 41
|
||||
#define WINHTTP_OPTION_CONTEXT_VALUE 45
|
||||
#define WINHTTP_OPTION_CLIENT_CERT_CONTEXT 47
|
||||
@@ -141,7 +150,35 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define WINHTTP_OPTION_UNLOAD_NOTIFY_EVENT 99
|
||||
#define WINHTTP_OPTION_REJECT_USERPWD_IN_URL 100
|
||||
#define WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS 101
|
||||
#define WINHTTP_LAST_OPTION WINHTTP_OPTION_USE_GLOBAL_SERVER_CREDENTIALS
|
||||
#define WINHTTP_OPTION_RECEIVE_PROXY_CONNECT_RESPONSE 103
|
||||
#define WINHTTP_OPTION_IS_PROXY_CONNECT_RESPONSE 104
|
||||
#define WINHTTP_OPTION_SERVER_SPN_USED 106
|
||||
#define WINHTTP_OPTION_PROXY_SPN_USED 107
|
||||
#define WINHTTP_OPTION_SERVER_CBT 108
|
||||
#define WINHTTP_OPTION_UNSAFE_HEADER_PARSING 110
|
||||
#define WINHTTP_OPTION_ASSURED_NON_BLOCKING_CALLBACKS 111
|
||||
#define WINHTTP_OPTION_UPGRADE_TO_WEB_SOCKET 114
|
||||
#define WINHTTP_OPTION_WEB_SOCKET_CLOSE_TIMEOUT 115
|
||||
#define WINHTTP_OPTION_WEB_SOCKET_KEEPALIVE_INTERVAL 116
|
||||
#define WINHTTP_OPTION_DECOMPRESSION 118
|
||||
#define WINHTTP_OPTION_WEB_SOCKET_RECEIVE_BUFFER_SIZE 122
|
||||
#define WINHTTP_OPTION_WEB_SOCKET_SEND_BUFFER_SIZE 123
|
||||
#define WINHTTP_OPTION_TCP_PRIORITY_HINT 128
|
||||
#define WINHTTP_OPTION_CONNECTION_FILTER 131
|
||||
#define WINHTTP_OPTION_ENABLE_HTTP_PROTOCOL 133
|
||||
#define WINHTTP_OPTION_HTTP_PROTOCOL_USED 134
|
||||
#define WINHTTP_OPTION_KDC_PROXY_SETTINGS 136
|
||||
#define WINHTTP_OPTION_ENCODE_EXTRA 138
|
||||
#define WINHTTP_OPTION_DISABLE_STREAM_QUEUE 139
|
||||
#define WINHTTP_OPTION_IPV6_FAST_FALLBACK 140
|
||||
#define WINHTTP_OPTION_CONNECTION_STATS_V0 141
|
||||
#define WINHTTP_OPTION_REQUEST_TIMES 142
|
||||
#define WINHTTP_OPTION_EXPIRE_CONNECTION 143
|
||||
#define WINHTTP_OPTION_DISABLE_SECURE_PROTOCOL_FALLBACK 144
|
||||
#define WINHTTP_OPTION_HTTP_PROTOCOL_REQUIRED 145
|
||||
#define WINHTTP_OPTION_REQUEST_STATS 146
|
||||
#define WINHTTP_OPTION_SERVER_CERT_CHAIN_CONTEXT 147
|
||||
#define WINHTTP_LAST_OPTION WINHTTP_OPTION_SERVER_CERT_CHAIN_CONTEXT
|
||||
#define WINHTTP_OPTION_USERNAME 0x1000
|
||||
#define WINHTTP_OPTION_PASSWORD 0x1001
|
||||
#define WINHTTP_OPTION_PROXY_USERNAME 0x1002
|
||||
@@ -149,6 +186,15 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
|
||||
#define WINHTTP_CONNS_PER_SERVER_UNLIMITED 0xFFFFFFFF
|
||||
|
||||
#define WINHTTP_DECOMPRESSION_FLAG_GZIP 0x00000001
|
||||
#define WINHTTP_DECOMPRESSION_FLAG_DEFLATE 0x00000002
|
||||
|
||||
#define WINHTTP_DECOMPRESSION_FLAG_ALL ( WINHTTP_DECOMPRESSION_FLAG_GZIP | WINHTTP_DECOMPRESSION_FLAG_DEFLATE )
|
||||
|
||||
#define WINHTTP_PROTOCOL_FLAG_HTTP2 0x1
|
||||
#define WINHTTP_PROTOCOL_FLAG_HTTP3 0x2
|
||||
#define WINHTTP_PROTOCOL_MASK (WINHTTP_PROTOCOL_FLAG_HTTP2 | WINHTTP_PROTOCOL_FLAG_HTTP3)
|
||||
|
||||
#define WINHTTP_AUTOLOGON_SECURITY_LEVEL_MEDIUM 0
|
||||
#define WINHTTP_AUTOLOGON_SECURITY_LEVEL_LOW 1
|
||||
#define WINHTTP_AUTOLOGON_SECURITY_LEVEL_HIGH 2
|
||||
@@ -223,6 +269,8 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define ERROR_WINHTTP_SECURE_CERT_REVOKED (WINHTTP_ERROR_BASE + 170)
|
||||
#define ERROR_WINHTTP_NOT_INITIALIZED (WINHTTP_ERROR_BASE + 172)
|
||||
#define ERROR_WINHTTP_SECURE_FAILURE (WINHTTP_ERROR_BASE + 175)
|
||||
#define ERROR_WINHTTP_UNHANDLED_SCRIPT_TYPE (WINHTTP_ERROR_BASE + 176)
|
||||
#define ERROR_WINHTTP_SCRIPT_EXECUTION_ERROR (WINHTTP_ERROR_BASE + 177)
|
||||
#define ERROR_WINHTTP_AUTO_PROXY_SERVICE_ERROR (WINHTTP_ERROR_BASE + 178)
|
||||
#define ERROR_WINHTTP_SECURE_CERT_WRONG_USAGE (WINHTTP_ERROR_BASE + 179)
|
||||
#define ERROR_WINHTTP_AUTODETECTION_FAILED (WINHTTP_ERROR_BASE + 180)
|
||||
@@ -232,7 +280,20 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define ERROR_WINHTTP_RESPONSE_DRAIN_OVERFLOW (WINHTTP_ERROR_BASE + 184)
|
||||
#define ERROR_WINHTTP_CLIENT_CERT_NO_PRIVATE_KEY (WINHTTP_ERROR_BASE + 185)
|
||||
#define ERROR_WINHTTP_CLIENT_CERT_NO_ACCESS_PRIVATE_KEY (WINHTTP_ERROR_BASE + 186)
|
||||
#define WINHTTP_ERROR_LAST (WINHTTP_ERROR_BASE + 186)
|
||||
#define ERROR_WINHTTP_CLIENT_AUTH_CERT_NEEDED_PROXY (WINHTTP_ERROR_BASE + 187)
|
||||
#define ERROR_WINHTTP_SECURE_FAILURE_PROXY (WINHTTP_ERROR_BASE + 188)
|
||||
#define ERROR_WINHTTP_RESERVED_189 (WINHTTP_ERROR_BASE + 189)
|
||||
#define ERROR_WINHTTP_HTTP_PROTOCOL_MISMATCH (WINHTTP_ERROR_BASE + 190)
|
||||
#define WINHTTP_ERROR_LAST (WINHTTP_ERROR_BASE + 188)
|
||||
|
||||
#define WINHTTP_RESET_STATE 0x00000001
|
||||
#define WINHTTP_RESET_SWPAD_CURRENT_NETWORK 0x00000002
|
||||
#define WINHTTP_RESET_SWPAD_ALL 0x00000004
|
||||
#define WINHTTP_RESET_SCRIPT_CACHE 0x00000008
|
||||
#define WINHTTP_RESET_ALL 0x0000FFFF
|
||||
#define WINHTTP_RESET_NOTIFY_NETWORK_CHANGED 0x00010000
|
||||
#define WINHTTP_RESET_OUT_OF_PROC 0x00020000
|
||||
#define WINHTTP_RESET_DISCARD_RESOLVERS 0x00040000
|
||||
|
||||
/* WinHttp status codes */
|
||||
#define HTTP_STATUS_CONTINUE 100
|
||||
@@ -252,6 +313,7 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define HTTP_STATUS_NOT_MODIFIED 304
|
||||
#define HTTP_STATUS_USE_PROXY 305
|
||||
#define HTTP_STATUS_REDIRECT_KEEP_VERB 307
|
||||
#define HTTP_STATUS_PERMANENT_REDIRECT 308
|
||||
#define HTTP_STATUS_BAD_REQUEST 400
|
||||
#define HTTP_STATUS_DENIED 401
|
||||
#define HTTP_STATUS_PAYMENT_REQ 402
|
||||
@@ -375,6 +437,7 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define WINHTTP_QUERY_FLAG_REQUEST_HEADERS 0x80000000
|
||||
#define WINHTTP_QUERY_FLAG_SYSTEMTIME 0x40000000
|
||||
#define WINHTTP_QUERY_FLAG_NUMBER 0x20000000
|
||||
#define WINHTTP_QUERY_FLAG_NUMBER64 0x08000000
|
||||
|
||||
/* Callback options */
|
||||
#define WINHTTP_CALLBACK_STATUS_RESOLVING_NAME 0x00000001
|
||||
@@ -399,6 +462,11 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE 0x00100000
|
||||
#define WINHTTP_CALLBACK_STATUS_REQUEST_ERROR 0x00200000
|
||||
#define WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE 0x00400000
|
||||
#define WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE 0x01000000
|
||||
#define WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE 0x02000000
|
||||
#define WINHTTP_CALLBACK_STATUS_SHUTDOWN_COMPLETE 0x04000000
|
||||
#define WINHTTP_CALLBACK_STATUS_SETTINGS_WRITE_COMPLETE 0x10000000
|
||||
#define WINHTTP_CALLBACK_STATUS_SETTINGS_READ_COMPLETE 0x20000000
|
||||
#define WINHTTP_CALLBACK_FLAG_RESOLVE_NAME (WINHTTP_CALLBACK_STATUS_RESOLVING_NAME | WINHTTP_CALLBACK_STATUS_NAME_RESOLVED)
|
||||
#define WINHTTP_CALLBACK_FLAG_CONNECT_TO_SERVER (WINHTTP_CALLBACK_STATUS_CONNECTING_TO_SERVER | WINHTTP_CALLBACK_STATUS_CONNECTED_TO_SERVER)
|
||||
#define WINHTTP_CALLBACK_FLAG_SEND_REQUEST (WINHTTP_CALLBACK_STATUS_SENDING_REQUEST | WINHTTP_CALLBACK_STATUS_REQUEST_SENT)
|
||||
@@ -415,9 +483,11 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define WINHTTP_CALLBACK_FLAG_READ_COMPLETE WINHTTP_CALLBACK_STATUS_READ_COMPLETE
|
||||
#define WINHTTP_CALLBACK_FLAG_WRITE_COMPLETE WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE
|
||||
#define WINHTTP_CALLBACK_FLAG_REQUEST_ERROR WINHTTP_CALLBACK_STATUS_REQUEST_ERROR
|
||||
#define WINHTTP_CALLBACK_FLAG_GETPROXYFORURL_COMPLETE WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE
|
||||
#define WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS (WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE | WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE \
|
||||
| WINHTTP_CALLBACK_STATUS_DATA_AVAILABLE | WINHTTP_CALLBACK_STATUS_READ_COMPLETE \
|
||||
| WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR)
|
||||
| WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE | WINHTTP_CALLBACK_STATUS_REQUEST_ERROR \
|
||||
| WINHTTP_CALLBACK_STATUS_GETPROXYFORURL_COMPLETE)
|
||||
#define WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS 0xffffffff
|
||||
#define WINHTTP_INVALID_STATUS_CALLBACK ((WINHTTP_STATUS_CALLBACK)(-1))
|
||||
|
||||
@@ -426,6 +496,7 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define API_READ_DATA (3)
|
||||
#define API_WRITE_DATA (4)
|
||||
#define API_SEND_REQUEST (5)
|
||||
#define API_GET_PROXY_FOR_URL (6)
|
||||
|
||||
#define WINHTTP_HANDLE_TYPE_SESSION 1
|
||||
#define WINHTTP_HANDLE_TYPE_CONNECT 2
|
||||
@@ -445,6 +516,7 @@ typedef int INTERNET_SCHEME, *LPINTERNET_SCHEME;
|
||||
#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1 0x00000080
|
||||
#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_1 0x00000200
|
||||
#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_2 0x00000800
|
||||
#define WINHTTP_FLAG_SECURE_PROTOCOL_TLS1_3 0x00002000
|
||||
#define WINHTTP_FLAG_SECURE_PROTOCOL_ALL (WINHTTP_FLAG_SECURE_PROTOCOL_SSL2 |\
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_SSL3 |\
|
||||
WINHTTP_FLAG_SECURE_PROTOCOL_TLS1)
|
||||
@@ -524,13 +596,24 @@ typedef VOID
|
||||
_In_ LPVOID,
|
||||
_In_ DWORD);
|
||||
|
||||
typedef WINHTTP_STATUS_CALLBACK * LPWINHTTP_STATUS_CALLBACK;
|
||||
|
||||
#define WINHTTP_AUTO_DETECT_TYPE_DHCP 0x00000001
|
||||
#define WINHTTP_AUTO_DETECT_TYPE_DNS_A 0x00000002
|
||||
|
||||
#define WINHTTP_AUTOPROXY_AUTO_DETECT 0x00000001
|
||||
#define WINHTTP_AUTOPROXY_CONFIG_URL 0x00000002
|
||||
#define WINHTTP_AUTOPROXY_HOST_KEEPCASE 0x00000004
|
||||
#define WINHTTP_AUTOPROXY_HOST_LOWERCASE 0x00000008
|
||||
#define WINHTTP_AUTOPROXY_ALLOW_AUTOCONFIG 0x00000100
|
||||
#define WINHTTP_AUTOPROXY_ALLOW_STATIC 0x00000200
|
||||
#define WINHTTP_AUTOPROXY_ALLOW_CM 0x00000400
|
||||
#define WINHTTP_AUTOPROXY_RUN_INPROCESS 0x00010000
|
||||
#define WINHTTP_AUTOPROXY_RUN_OUTPROCESS_ONLY 0x00020000
|
||||
#define WINHTTP_AUTOPROXY_NO_DIRECTACCESS 0x00040000
|
||||
#define WINHTTP_AUTOPROXY_NO_CACHE_CLIENT 0x00080000
|
||||
#define WINHTTP_AUTOPROXY_NO_CACHE_SVC 0x00100000
|
||||
#define WINHTTP_AUTOPROXY_SORT_RESULTS 0x00400000
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@@ -542,6 +625,56 @@ typedef struct
|
||||
BOOL fAutoLogonIfChallenged;
|
||||
} WINHTTP_AUTOPROXY_OPTIONS;
|
||||
|
||||
typedef struct _WINHTTP_PROXY_RESULT_ENTRY
|
||||
{
|
||||
BOOL fProxy;
|
||||
BOOL fBypass;
|
||||
INTERNET_SCHEME ProxyScheme;
|
||||
PWSTR pwszProxy;
|
||||
INTERNET_PORT ProxyPort;
|
||||
} WINHTTP_PROXY_RESULT_ENTRY;
|
||||
|
||||
typedef struct _WINHTTP_PROXY_RESULT
|
||||
{
|
||||
DWORD cEntries;
|
||||
WINHTTP_PROXY_RESULT_ENTRY *pEntries;
|
||||
} WINHTTP_PROXY_RESULT;
|
||||
|
||||
typedef struct _WINHTTP_PROXY_RESULT_EX
|
||||
{
|
||||
DWORD cEntries;
|
||||
WINHTTP_PROXY_RESULT_ENTRY *pEntries;
|
||||
HANDLE hProxyDetectionHandle;
|
||||
DWORD dwProxyInterfaceAffinity;
|
||||
} WINHTTP_PROXY_RESULT_EX;
|
||||
|
||||
#define NETWORKING_KEY_BUFSIZE 128
|
||||
|
||||
typedef struct _WinHttpProxyNetworkKey
|
||||
{
|
||||
unsigned char pbBuffer[NETWORKING_KEY_BUFSIZE];
|
||||
} WINHTTP_PROXY_NETWORKING_KEY, *PWINHTTP_PROXY_NETWORKING_KEY;
|
||||
|
||||
typedef struct _WINHTTP_PROXY_SETTINGS
|
||||
{
|
||||
DWORD dwStructSize;
|
||||
DWORD dwFlags;
|
||||
DWORD dwCurrentSettingsVersion;
|
||||
PWSTR pwszConnectionName;
|
||||
PWSTR pwszProxy;
|
||||
PWSTR pwszProxyBypass;
|
||||
PWSTR pwszAutoconfigUrl;
|
||||
PWSTR pwszAutoconfigSecondaryUrl;
|
||||
DWORD dwAutoDiscoveryFlags;
|
||||
PWSTR pwszLastKnownGoodAutoConfigUrl;
|
||||
DWORD dwAutoconfigReloadDelayMins;
|
||||
FILETIME ftLastKnownDetectTime;
|
||||
DWORD dwDetectedInterfaceIpCount;
|
||||
PDWORD pdwDetectedInterfaceIp;
|
||||
DWORD cNetworkKeys;
|
||||
PWINHTTP_PROXY_NETWORKING_KEY pNetworkKeys;
|
||||
} WINHTTP_PROXY_SETTINGS, *PWINHTTP_PROXY_SETTINGS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwMajorVersion;
|
||||
@@ -557,6 +690,139 @@ typedef struct
|
||||
} WINHTTP_CONNECTION_INFO;
|
||||
#endif
|
||||
|
||||
typedef enum _WINHTTP_REQUEST_TIME_ENTRY
|
||||
{
|
||||
WinHttpProxyDetectionStart = 0,
|
||||
WinHttpProxyDetectionEnd,
|
||||
WinHttpConnectionAcquireStart,
|
||||
WinHttpConnectionAcquireWaitEnd,
|
||||
WinHttpConnectionAcquireEnd,
|
||||
WinHttpNameResolutionStart,
|
||||
WinHttpNameResolutionEnd,
|
||||
WinHttpConnectionEstablishmentStart,
|
||||
WinHttpConnectionEstablishmentEnd,
|
||||
WinHttpTlsHandshakeClientLeg1Start,
|
||||
WinHttpTlsHandshakeClientLeg1End,
|
||||
WinHttpTlsHandshakeClientLeg2Start,
|
||||
WinHttpTlsHandshakeClientLeg2End,
|
||||
WinHttpTlsHandshakeClientLeg3Start,
|
||||
WinHttpTlsHandshakeClientLeg3End,
|
||||
WinHttpStreamWaitStart,
|
||||
WinHttpStreamWaitEnd,
|
||||
WinHttpSendRequestStart,
|
||||
WinHttpSendRequestHeadersCompressionStart,
|
||||
WinHttpSendRequestHeadersCompressionEnd,
|
||||
WinHttpSendRequestHeadersEnd,
|
||||
WinHttpSendRequestEnd,
|
||||
WinHttpReceiveResponseStart,
|
||||
WinHttpReceiveResponseHeadersDecompressionStart,
|
||||
WinHttpReceiveResponseHeadersDecompressionEnd,
|
||||
WinHttpReceiveResponseHeadersEnd,
|
||||
WinHttpReceiveResponseBodyDecompressionDelta,
|
||||
WinHttpReceiveResponseEnd,
|
||||
WinHttpProxyTunnelStart,
|
||||
WinHttpProxyTunnelEnd,
|
||||
WinHttpProxyTlsHandshakeClientLeg1Start,
|
||||
WinHttpProxyTlsHandshakeClientLeg1End,
|
||||
WinHttpProxyTlsHandshakeClientLeg2Start,
|
||||
WinHttpProxyTlsHandshakeClientLeg2End,
|
||||
WinHttpProxyTlsHandshakeClientLeg3Start,
|
||||
WinHttpProxyTlsHandshakeClientLeg3End,
|
||||
WinHttpRequestTimeLast,
|
||||
WinHttpRequestTimeMax = 64
|
||||
} WINHTTP_REQUEST_TIME_ENTRY;
|
||||
|
||||
typedef struct _WINHTTP_REQUEST_TIMES
|
||||
{
|
||||
ULONG cTimes;
|
||||
ULONGLONG rgullTimes[WinHttpRequestTimeMax];
|
||||
} WINHTTP_REQUEST_TIMES, *PWINHTTP_REQUEST_TIMES;
|
||||
|
||||
typedef enum _WINHTTP_REQUEST_STAT_ENTRY
|
||||
{
|
||||
WinHttpConnectFailureCount = 0,
|
||||
WinHttpProxyFailureCount,
|
||||
WinHttpTlsHandshakeClientLeg1Size,
|
||||
WinHttpTlsHandshakeServerLeg1Size,
|
||||
WinHttpTlsHandshakeClientLeg2Size,
|
||||
WinHttpTlsHandshakeServerLeg2Size,
|
||||
WinHttpRequestHeadersSize,
|
||||
WinHttpRequestHeadersCompressedSize,
|
||||
WinHttpResponseHeadersSize,
|
||||
WinHttpResponseHeadersCompressedSize,
|
||||
WinHttpResponseBodySize,
|
||||
WinHttpResponseBodyCompressedSize,
|
||||
WinHttpProxyTlsHandshakeClientLeg1Size,
|
||||
WinHttpProxyTlsHandshakeServerLeg1Size,
|
||||
WinHttpProxyTlsHandshakeClientLeg2Size,
|
||||
WinHttpProxyTlsHandshakeServerLeg2Size,
|
||||
WinHttpRequestStatLast,
|
||||
WinHttpRequestStatMax = 32
|
||||
} WINHTTP_REQUEST_STAT_ENTRY;
|
||||
|
||||
#define WINHTTP_REQUEST_STAT_FLAG_TCP_FAST_OPEN 0x00000001
|
||||
#define WINHTTP_REQUEST_STAT_FLAG_TLS_SESSION_RESUMPTION 0x00000002
|
||||
#define WINHTTP_REQUEST_STAT_FLAG_TLS_FALSE_START 0x00000004
|
||||
#define WINHTTP_REQUEST_STAT_FLAG_PROXY_TLS_SESSION_RESUMPTION 0x00000008
|
||||
#define WINHTTP_REQUEST_STAT_FLAG_PROXY_TLS_FALSE_START 0x00000010
|
||||
#define WINHTTP_REQUEST_STAT_FLAG_FIRST_REQUEST 0x00000020
|
||||
|
||||
typedef struct _WINHTTP_REQUEST_STATS
|
||||
{
|
||||
ULONGLONG ullFlags;
|
||||
ULONG ulIndex;
|
||||
ULONG cStats;
|
||||
ULONGLONG rgullStats[WinHttpRequestStatMax];
|
||||
} WINHTTP_REQUEST_STATS, *PWINHTTP_REQUEST_STATS;
|
||||
|
||||
typedef enum _WINHTTP_WEB_SOCKET_OPERATION
|
||||
{
|
||||
WINHTTP_WEB_SOCKET_SEND_OPERATION = 0,
|
||||
WINHTTP_WEB_SOCKET_RECEIVE_OPERATION = 1,
|
||||
WINHTTP_WEB_SOCKET_CLOSE_OPERATION = 2,
|
||||
WINHTTP_WEB_SOCKET_SHUTDOWN_OPERATION = 3
|
||||
} WINHTTP_WEB_SOCKET_OPERATION;
|
||||
|
||||
typedef enum _WINHTTP_WEB_SOCKET_BUFFER_TYPE
|
||||
{
|
||||
WINHTTP_WEB_SOCKET_BINARY_MESSAGE_BUFFER_TYPE = 0,
|
||||
WINHTTP_WEB_SOCKET_BINARY_FRAGMENT_BUFFER_TYPE = 1,
|
||||
WINHTTP_WEB_SOCKET_UTF8_MESSAGE_BUFFER_TYPE = 2,
|
||||
WINHTTP_WEB_SOCKET_UTF8_FRAGMENT_BUFFER_TYPE = 3,
|
||||
WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE = 4
|
||||
} WINHTTP_WEB_SOCKET_BUFFER_TYPE;
|
||||
|
||||
typedef enum _WINHTTP_WEB_SOCKET_CLOSE_STATUS
|
||||
{
|
||||
WINHTTP_WEB_SOCKET_SUCCESS_CLOSE_STATUS = 1000,
|
||||
WINHTTP_WEB_SOCKET_ENDPOINT_TERMINATED_CLOSE_STATUS = 1001,
|
||||
WINHTTP_WEB_SOCKET_PROTOCOL_ERROR_CLOSE_STATUS = 1002,
|
||||
WINHTTP_WEB_SOCKET_INVALID_DATA_TYPE_CLOSE_STATUS = 1003,
|
||||
WINHTTP_WEB_SOCKET_EMPTY_CLOSE_STATUS = 1005,
|
||||
WINHTTP_WEB_SOCKET_ABORTED_CLOSE_STATUS = 1006,
|
||||
WINHTTP_WEB_SOCKET_INVALID_PAYLOAD_CLOSE_STATUS = 1007,
|
||||
WINHTTP_WEB_SOCKET_POLICY_VIOLATION_CLOSE_STATUS = 1008,
|
||||
WINHTTP_WEB_SOCKET_MESSAGE_TOO_BIG_CLOSE_STATUS = 1009,
|
||||
WINHTTP_WEB_SOCKET_UNSUPPORTED_EXTENSIONS_CLOSE_STATUS = 1010,
|
||||
WINHTTP_WEB_SOCKET_SERVER_ERROR_CLOSE_STATUS = 1011,
|
||||
WINHTTP_WEB_SOCKET_SECURE_HANDSHAKE_ERROR_CLOSE_STATUS = 1015
|
||||
} WINHTTP_WEB_SOCKET_CLOSE_STATUS;
|
||||
|
||||
typedef struct _WINHTTP_WEB_SOCKET_ASYNC_RESULT
|
||||
{
|
||||
WINHTTP_ASYNC_RESULT AsyncResult;
|
||||
WINHTTP_WEB_SOCKET_OPERATION Operation;
|
||||
} WINHTTP_WEB_SOCKET_ASYNC_RESULT;
|
||||
|
||||
typedef struct _WINHTTP_WEB_SOCKET_STATUS
|
||||
{
|
||||
DWORD dwBytesTransferred;
|
||||
WINHTTP_WEB_SOCKET_BUFFER_TYPE eBufferType;
|
||||
} WINHTTP_WEB_SOCKET_STATUS;
|
||||
|
||||
#define WINHTTP_WEB_SOCKET_MAX_CLOSE_REASON_LENGTH 123
|
||||
#define WINHTTP_WEB_SOCKET_MIN_KEEPALIVE_VALUE 15000
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@@ -596,6 +862,13 @@ WinHttpCrackUrl(
|
||||
_In_ DWORD,
|
||||
_Inout_ LPURL_COMPONENTS);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpCreateProxyResolver(
|
||||
_Out_ HINTERNET,
|
||||
_Out_ HINTERNET*);
|
||||
|
||||
_Success_(return != 0)
|
||||
BOOL
|
||||
WINAPI
|
||||
@@ -605,6 +878,18 @@ WinHttpCreateUrl(
|
||||
_Out_writes_to_opt_(*pdwUrlLength, *pdwUrlLength) LPWSTR,
|
||||
_Inout_ LPDWORD pdwUrlLength);
|
||||
|
||||
void
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpFreeProxyResult(
|
||||
_Inout_ WINHTTP_PROXY_RESULT*);
|
||||
|
||||
void
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpFreeProxyResultEx(
|
||||
_Inout_ WINHTTP_PROXY_RESULT_EX*);
|
||||
|
||||
BOOL
|
||||
WINAPI
|
||||
WinHttpGetDefaultProxyConfiguration(
|
||||
@@ -616,6 +901,7 @@ WinHttpGetIEProxyConfigForCurrentUser(
|
||||
_Inout_ WINHTTP_CURRENT_USER_IE_PROXY_CONFIG*);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpGetProxyForUrl(
|
||||
_In_ HINTERNET,
|
||||
@@ -623,7 +909,59 @@ WinHttpGetProxyForUrl(
|
||||
_In_ WINHTTP_AUTOPROXY_OPTIONS*,
|
||||
_Out_ WINHTTP_PROXY_INFO*);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpGetProxyForUrlEx(
|
||||
_In_ HINTERNET,
|
||||
_In_ PCWSTR,
|
||||
_In_ WINHTTP_AUTOPROXY_OPTIONS*,
|
||||
_Out_ DWORD_PTR);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpGetProxyForUrlEx2(
|
||||
_In_ HINTERNET,
|
||||
_In_ PCWSTR,
|
||||
_In_ WINHTTP_AUTOPROXY_OPTIONS*,
|
||||
DWORD,
|
||||
BYTE*,
|
||||
_Out_ DWORD_PTR);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpGetProxyResult(
|
||||
_In_ HINTERNET,
|
||||
_Out_ WINHTTP_PROXY_RESULT*);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpGetProxyResultEx(
|
||||
_In_ HINTERNET,
|
||||
_Out_ WINHTTP_PROXY_RESULT_EX*);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpGetProxySettingsVersion(
|
||||
_In_ HINTERNET,
|
||||
_Out_ DWORD*);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpIsHostInProxyBypassList(
|
||||
_In_ const WINHTTP_PROXY_INFO*,
|
||||
_In_ PCWSTR,
|
||||
_In_ INTERNET_SCHEME,
|
||||
_In_ INTERNET_PORT,
|
||||
_Inout_ BOOL*);
|
||||
|
||||
HINTERNET
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpOpen(
|
||||
_In_opt_z_ LPCWSTR,
|
||||
@@ -633,6 +971,7 @@ WinHttpOpen(
|
||||
_In_ DWORD);
|
||||
|
||||
HINTERNET
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpOpenRequest(
|
||||
_In_ HINTERNET,
|
||||
@@ -644,6 +983,7 @@ WinHttpOpenRequest(
|
||||
_In_ DWORD);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpQueryAuthParams(
|
||||
_In_ HINTERNET,
|
||||
@@ -651,6 +991,7 @@ WinHttpQueryAuthParams(
|
||||
_Out_ LPVOID*);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpQueryAuthSchemes(
|
||||
_In_ HINTERNET,
|
||||
@@ -659,6 +1000,7 @@ WinHttpQueryAuthSchemes(
|
||||
_Out_ LPDWORD);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpQueryDataAvailable(
|
||||
_In_ HINTERNET,
|
||||
@@ -666,6 +1008,7 @@ WinHttpQueryDataAvailable(
|
||||
|
||||
_Success_(return != 0)
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpQueryHeaders(
|
||||
_In_ HINTERNET,
|
||||
@@ -677,6 +1020,7 @@ WinHttpQueryHeaders(
|
||||
|
||||
_Success_(return != 0)
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpQueryOption(
|
||||
_In_ HINTERNET,
|
||||
@@ -685,6 +1029,7 @@ WinHttpQueryOption(
|
||||
_Inout_ LPDWORD lpdwBufferLength);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpReadData(
|
||||
_In_ HINTERNET,
|
||||
@@ -692,9 +1037,24 @@ WinHttpReadData(
|
||||
_In_ DWORD dwNumberOfBytesToRead,
|
||||
_Out_ LPDWORD lpdwNumberOfBytesRead);
|
||||
|
||||
BOOL WINAPI WinHttpReceiveResponse(_In_ HINTERNET, _Reserved_ LPVOID);
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpReadProxySettings(
|
||||
_In_ HINTERNET,
|
||||
PCWSTR,
|
||||
BOOL,
|
||||
BOOL,
|
||||
LPDWORD,
|
||||
BOOL*,
|
||||
_Out_ PWINHTTP_PROXY_SETTINGS);
|
||||
|
||||
BOOL WINHTTPAPI WINAPI WinHttpReceiveResponse(_In_ HINTERNET, _Reserved_ LPVOID);
|
||||
|
||||
DWORD WINHTTPAPI WINAPI WinHttpResetAutoProxy(_In_ HINTERNET, _In_ DWORD);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpSendRequest(
|
||||
_In_ HINTERNET,
|
||||
@@ -706,11 +1066,13 @@ WinHttpSendRequest(
|
||||
_In_ DWORD_PTR);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpSetDefaultProxyConfiguration(
|
||||
_In_ WINHTTP_PROXY_INFO*);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpSetCredentials(
|
||||
_In_ HINTERNET,
|
||||
@@ -721,6 +1083,7 @@ WinHttpSetCredentials(
|
||||
_Reserved_ LPVOID);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpSetOption(
|
||||
_In_opt_ HINTERNET,
|
||||
@@ -741,6 +1104,7 @@ WinHttpSetOption(
|
||||
_In_ DWORD dwBufferLength);
|
||||
|
||||
WINHTTP_STATUS_CALLBACK
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpSetStatusCallback(
|
||||
_In_ HINTERNET,
|
||||
@@ -749,6 +1113,7 @@ WinHttpSetStatusCallback(
|
||||
_Reserved_ DWORD_PTR);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpSetTimeouts(
|
||||
_In_ HINTERNET,
|
||||
@@ -758,6 +1123,7 @@ WinHttpSetTimeouts(
|
||||
_In_ int);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpTimeFromSystemTime(
|
||||
_In_ CONST SYSTEMTIME *,
|
||||
@@ -765,7 +1131,62 @@ WinHttpTimeFromSystemTime(
|
||||
|
||||
BOOL WINAPI WinHttpTimeToSystemTime(_In_z_ LPCWSTR, _Out_ SYSTEMTIME*);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpWebSocketClose(
|
||||
_In_ HINTERNET,
|
||||
_In_ USHORT,
|
||||
_In_opt_ PVOID,
|
||||
_In_ DWORD);
|
||||
|
||||
HINTERNET
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpWebSocketCompleteUpgrade(
|
||||
_In_ HINTERNET,
|
||||
_In_opt_ DWORD_PTR);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpWebSocketQueryCloseStatus(
|
||||
_In_ HINTERNET,
|
||||
_Out_ USHORT*,
|
||||
_Out_ void*,
|
||||
_In_ DWORD,
|
||||
_Out_ DWORD*);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpWebSocketReceive(
|
||||
_In_ HINTERNET,
|
||||
_Out_ PVOID,
|
||||
_In_ DWORD,
|
||||
_Out_ DWORD*,
|
||||
_Out_ WINHTTP_WEB_SOCKET_BUFFER_TYPE*);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpWebSocketSend(
|
||||
_In_ HINTERNET,
|
||||
_In_ WINHTTP_WEB_SOCKET_BUFFER_TYPE,
|
||||
_In_reads_bytes_(dwBufferLength) PVOID pvBuffer,
|
||||
_In_ DWORD dwBufferLength);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpWebSocketShutdown(
|
||||
_In_ HINTERNET,
|
||||
_In_ USHORT,
|
||||
_In_reads_bytes_(dwReasonLength) _In_opt_ void* pvReason,
|
||||
_In_ DWORD dwReasonLength);
|
||||
|
||||
BOOL
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpWriteData(
|
||||
_In_ HINTERNET,
|
||||
@@ -773,6 +1194,14 @@ WinHttpWriteData(
|
||||
_In_ DWORD dwNumberOfBytesToWrite,
|
||||
_Out_ LPDWORD);
|
||||
|
||||
DWORD
|
||||
WINHTTPAPI
|
||||
WINAPI
|
||||
WinHttpWriteProxySettings(
|
||||
_In_ HINTERNET,
|
||||
BOOL,
|
||||
_In_ PWINHTTP_PROXY_SETTINGS);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -308,6 +308,12 @@ typedef USHORT ADDRESS_FAMILY;
|
||||
|
||||
#define AI_DISABLE_IDN_ENCODING 0x00080000
|
||||
|
||||
#ifndef USE_WS_PREFIX
|
||||
#define AI_DNS_ONLY 0x00000010
|
||||
#else
|
||||
#define WS_AI_DNS_ONLY 0x00000010
|
||||
#endif
|
||||
|
||||
#define NS_ALL 0
|
||||
|
||||
#define NS_SAP 1
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
directories:
|
||||
dlls/winhttp: dll/win32/winhttp
|
||||
dlls/winhttp/tests: modules/rostests/winetests/winhttp
|
||||
files:
|
||||
include/winhttp.h: sdk/include/psdk/winhttp.h
|
||||
tags:
|
||||
wine: wine-10.0
|
||||
Reference in New Issue
Block a user