winhttp: Get rid of domain_t.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2018-11-06 16:08:59 +01:00 committed by Alexandre Julliard
parent ef26d7d422
commit 2ee89aa257
3 changed files with 30 additions and 24 deletions

View File

@ -38,11 +38,18 @@ struct cookie
WCHAR *path; WCHAR *path;
}; };
static domain_t *add_domain( session_t *session, WCHAR *name ) struct domain
{ {
domain_t *domain; struct list entry;
WCHAR *name;
struct list cookies;
};
if (!(domain = heap_alloc_zero( sizeof(domain_t) ))) return NULL; static struct domain *add_domain( session_t *session, WCHAR *name )
{
struct domain *domain;
if (!(domain = heap_alloc_zero( sizeof(struct domain) ))) return NULL;
list_init( &domain->entry ); list_init( &domain->entry );
list_init( &domain->cookies ); list_init( &domain->cookies );
@ -54,7 +61,7 @@ static domain_t *add_domain( session_t *session, WCHAR *name )
return domain; return domain;
} }
static struct cookie *find_cookie( domain_t *domain, const WCHAR *path, const WCHAR *name ) static struct cookie *find_cookie( struct domain *domain, const WCHAR *path, const WCHAR *name )
{ {
struct list *item; struct list *item;
struct cookie *cookie; struct cookie *cookie;
@ -71,7 +78,7 @@ static struct cookie *find_cookie( domain_t *domain, const WCHAR *path, const WC
return NULL; return NULL;
} }
static BOOL domain_match( const WCHAR *name, domain_t *domain, BOOL partial ) 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)); TRACE("comparing %s with %s\n", debugstr_w(name), debugstr_w(domain->name));
@ -94,7 +101,7 @@ static void delete_cookie( struct cookie *cookie )
free_cookie( cookie ); free_cookie( cookie );
} }
void delete_domain( domain_t *domain ) static void delete_domain( struct domain *domain )
{ {
struct cookie *cookie; struct cookie *cookie;
struct list *item, *next; struct list *item, *next;
@ -110,9 +117,21 @@ void delete_domain( domain_t *domain )
heap_free( domain ); heap_free( domain );
} }
void destroy_cookies( session_t *session )
{
struct list *item, *next;
struct domain *domain;
LIST_FOR_EACH_SAFE( item, next, &session->cookie_cache )
{
domain = LIST_ENTRY( item, struct domain, entry );
delete_domain( domain );
}
}
static BOOL add_cookie( session_t *session, struct cookie *cookie, WCHAR *domain_name, WCHAR *path ) static BOOL add_cookie( session_t *session, struct cookie *cookie, WCHAR *domain_name, WCHAR *path )
{ {
domain_t *domain = NULL; struct domain *domain = NULL;
struct cookie *old_cookie; struct cookie *old_cookie;
struct list *item; struct list *item;
@ -122,7 +141,7 @@ static BOOL add_cookie( session_t *session, struct cookie *cookie, WCHAR *domain
LIST_FOR_EACH( item, &session->cookie_cache ) LIST_FOR_EACH( item, &session->cookie_cache )
{ {
domain = LIST_ENTRY( item, domain_t, entry ); domain = LIST_ENTRY( item, struct domain, entry );
if (domain_match( domain_name, domain, FALSE )) break; if (domain_match( domain_name, domain, FALSE )) break;
domain = NULL; domain = NULL;
} }
@ -311,7 +330,7 @@ BOOL add_cookie_headers( request_t *request )
LIST_FOR_EACH( domain_cursor, &session->cookie_cache ) LIST_FOR_EACH( domain_cursor, &session->cookie_cache )
{ {
domain_t *domain = LIST_ENTRY( domain_cursor, domain_t, entry ); struct domain *domain = LIST_ENTRY( domain_cursor, struct domain, entry );
if (domain_match( request->connect->servername, domain, TRUE )) if (domain_match( request->connect->servername, domain, TRUE ))
{ {
struct list *cookie_cursor; struct list *cookie_cursor;

View File

@ -89,19 +89,13 @@ BOOL WINAPI WinHttpCheckPlatform( void )
static void session_destroy( object_header_t *hdr ) static void session_destroy( object_header_t *hdr )
{ {
session_t *session = (session_t *)hdr; session_t *session = (session_t *)hdr;
struct list *item, *next;
domain_t *domain;
TRACE("%p\n", session); TRACE("%p\n", session);
if (session->unload_event) SetEvent( session->unload_event ); if (session->unload_event) SetEvent( session->unload_event );
if (session->cred_handle_initialized) FreeCredentialsHandle( &session->cred_handle ); if (session->cred_handle_initialized) FreeCredentialsHandle( &session->cred_handle );
destroy_cookies( session );
LIST_FOR_EACH_SAFE( item, next, &session->cookie_cache )
{
domain = LIST_ENTRY( item, domain_t, entry );
delete_domain( domain );
}
session->cs.DebugInfo->Spare[0] = 0; session->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection( &session->cs ); DeleteCriticalSection( &session->cs );
heap_free( session->agent ); heap_free( session->agent );

View File

@ -66,13 +66,6 @@ struct _object_header_t
struct list children; struct list children;
}; };
typedef struct
{
struct list entry;
WCHAR *name;
struct list cookies;
} domain_t;
typedef struct { typedef struct {
struct list entry; struct list entry;
LONG ref; LONG ref;
@ -295,7 +288,7 @@ int netconn_get_cipher_strength( netconn_t * ) DECLSPEC_HIDDEN;
BOOL set_cookies( request_t *, const WCHAR * ) DECLSPEC_HIDDEN; BOOL set_cookies( request_t *, const WCHAR * ) DECLSPEC_HIDDEN;
BOOL add_cookie_headers( request_t * ) DECLSPEC_HIDDEN; BOOL add_cookie_headers( request_t * ) DECLSPEC_HIDDEN;
BOOL add_request_headers( request_t *, LPCWSTR, DWORD, DWORD ) DECLSPEC_HIDDEN; BOOL add_request_headers( request_t *, LPCWSTR, DWORD, DWORD ) DECLSPEC_HIDDEN;
void delete_domain( domain_t * ) DECLSPEC_HIDDEN; void destroy_cookies( session_t * ) DECLSPEC_HIDDEN;
BOOL set_server_for_hostname( connect_t *, LPCWSTR, INTERNET_PORT ) DECLSPEC_HIDDEN; BOOL set_server_for_hostname( connect_t *, LPCWSTR, INTERNET_PORT ) DECLSPEC_HIDDEN;
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN; void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;