45 #define RESPONSE_TIMEOUT 30 97 0, 0, { (
DWORD_PTR)(__FILE__
": cookie_cs") }
110 subdomain_ptr = *
ptr ==
'.' ?
ptr+1 :
ptr;
112 current_domain =
NULL;
116 current_domain = iter;
121 if(!current_domain) {
125 current_domain =
heap_alloc(
sizeof(*current_domain));
130 if(!current_domain->
domain) {
137 current_domain->
parent = prev_domain;
145 return current_domain;
147 prev_domain = current_domain;
157 static const WCHAR cookie_prefix[] = {
'C',
'o',
'o',
'k',
'i',
'e',
':'};
169 memcpy(
url, cookie_prefix,
sizeof(cookie_prefix));
206 return cookie_container;
212 cookie_container =
heap_alloc(
sizeof(*cookie_container));
213 if(!cookie_container)
222 cookie_container->
domain = cookie_domain;
228 return cookie_container;
233 return cookie_container;
249 new_cookie = heap_alloc_zero(
sizeof(*new_cookie));
253 new_cookie->
expiry = expiry;
314 char *
str =
NULL, *pbeg, *pend;
320 if(!cookie_container)
346 pend =
strchr(pbeg,
'\n');
353 pend =
strchr(pbeg,
'\n');
359 pbeg =
strchr(pend+1,
'\n');
403 char buf[64], *dyn_buf;
444 if(!dyn_buf || !
WriteFile(cookie_handle, dyn_buf,
strlen(dyn_buf), &bytes_written,
NULL)) {
450 if(!
WriteFile(cookie_handle,
"\n", 1, &bytes_written,
NULL)) {
456 if(!dyn_buf || !
WriteFile(cookie_handle, dyn_buf,
strlen(dyn_buf), &bytes_written,
NULL)) {
462 if(!
WriteFile(cookie_handle,
"\n", 1, &bytes_written,
NULL)) {
468 if(!dyn_buf || !
WriteFile(cookie_handle, dyn_buf,
strlen(dyn_buf), &bytes_written,
NULL)) {
481 if(!dyn_buf || !
WriteFile(cookie_handle, dyn_buf,
strlen(dyn_buf), &bytes_written,
NULL)) {
499 ERR(
"error saving cookie file\n");
545 while(
p >
host.str &&
p[-1] !=
'.')
p--;
546 while(
p !=
host.str) {
548 while(
p >
host.str &&
p[-1] !=
'.')
p--;
549 if(
p ==
host.str)
break;
559 while(
p >
path.str &&
p[-1] !=
'/')
p--;
560 }
while(
p !=
path.str);
581 TRACE(
"Found expired cookie. deleting\n");
594 }
else if(
res->cnt ==
res->size) {
598 res->cookies = new_cookies;
606 res->string_len += 2;
607 res->cookies[
res->cnt++] = cookie_iter;
610 if(*cookie_iter->
data)
624 for(
i=0;
i<cookie_set->
cnt;
i++) {
651 static const WCHAR cookieW[] = {
'C',
'o',
'o',
'k',
'i',
'e',
':',
' '};
737 TRACE(
"(%s, %s, %p, %p, %x, %p)\n",
debugstr_w(lpszUrl),
debugstr_w(lpszCookieName), lpCookieData,
lpdwSize,
flags,
reserved);
873 if(!
domain.len || *
domain.str ==
'.' || !full_domain.
len || *full_domain.
str ==
'.') {
897 if (!
domain || !full_domain) {
917 const WCHAR *end_ptr;
925 memset(&expiry,0,
sizeof(expiry));
937 static const WCHAR szDomain[] = {
'd',
'o',
'm',
'a',
'i',
'n',
'='};
938 static const WCHAR szPath[] = {
'p',
'a',
't',
'h',
'='};
939 static const WCHAR szExpires[] = {
'e',
'x',
'p',
'i',
'r',
'e',
's',
'='};
940 static const WCHAR szSecure[] = {
's',
'e',
'c',
'u',
'r',
'e'};
941 static const WCHAR szHttpOnly[] = {
'h',
't',
't',
'p',
'o',
'n',
'l',
'y'};
942 static const WCHAR szVersion[] = {
'v',
'e',
'r',
's',
'i',
'o',
'n',
'='};
943 static const WCHAR max_ageW[] = {
'm',
'a',
'x',
'-',
'a',
'g',
'e',
'='};
987 TRACE(
"Cookie already expired.\n");
994 FIXME(
"secure not handled\n");
999 WARN(
"HTTP only cookie added without INTERNET_COOKIE_HTTPONLY flag\n");
1011 WARN(
"Max-Age ignored\n");
1012 }
else if(
data.len) {
1032 update_persistent =
TRUE;
1036 WARN(
"An attempt to override httponly cookie\n");
1043 update_persistent =
TRUE;
1089 if (!lpszUrl || !lpCookieData)
1098 if (!lpszCookieName) {
1210 FIXME(
"(%s, %p, %p, 0x%08x) stub\n",
1211 debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
1228 FIXME(
"(%s, %p, %p, 0x%08x) stub\n",
1229 debugstr_w(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
BOOL WINAPI CreateUrlCacheEntryW(LPCWSTR lpszUrlName, DWORD dwExpectedFileSize, LPCWSTR lpszFileExtension, LPWSTR lpszFileName, DWORD dwReserved)
#define ERROR_INVALID_PARAMETER
BOOL WINAPI InternetGetCookieW(const WCHAR *url, const WCHAR *name, WCHAR *data, DWORD *size)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
static cookie_container_t * get_cookie_container(substr_t domain, substr_t path, BOOL create)
VOID WINAPI GetSystemTimeAsFileTime(OUT PFILETIME lpFileTime)
struct _cookie_t cookie_t
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
BOOL WINAPI InternetGetCookieExW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, LPWSTR lpCookieData, LPDWORD lpdwSize, DWORD flags, void *reserved)
static LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
#define INTERNET_COOKIE_IS_SESSION
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
BOOL WINAPI InternetGetCookieExA(LPCSTR lpszUrl, LPCSTR lpszCookieName, LPSTR lpCookieData, LPDWORD lpdwSize, DWORD flags, void *reserved)
#define WideCharToMultiByte
static BOOL is_domain_legal_for_cookie(substr_t domain, substr_t full_domain)
static void substr_skip(substr_t *str, size_t len)
#define ERROR_NO_MORE_ITEMS
static substr_t substrz(const WCHAR *str)
ACPI_SIZE strlen(const char *String)
BOOL WINAPI InternetClearAllPerSiteCookieDecisions(VOID)
GLsizei const GLchar ** path
GLdouble GLdouble GLdouble r
static time_t create_time
struct list subdomain_list
static void free_cookie_domain_list(struct list *list)
#define ERROR_NOT_ENOUGH_MEMORY
#define INVALID_HANDLE_VALUE
DWORD WINAPI GetLastError(VOID)
struct _cookie_domain_t cookie_domain_t
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
_CONST_RETURN wchar_t *__cdecl wmemchr(_In_reads_(_N) const wchar_t *_S, _In_ wchar_t _C, _In_ size_t _N)
static void * heap_realloc(void *mem, size_t len)
static void * heap_alloc(size_t len)
BOOL WINAPI IsDomainLegalCookieDomainW(const WCHAR *domain, const WCHAR *full_domain)
BOOL WINAPI InternetGetPerSiteCookieDecisionW(LPCWSTR pwchHostName, ULONG *pResult)
__WINE_SERVER_LIST_INLINE struct list * list_head(const struct list *list)
DWORD WINAPI InternetSetCookieExW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName, LPCWSTR lpCookieData, DWORD flags, DWORD_PTR reserved)
WINE_DEFAULT_DEBUG_CHANNEL(winhttp)
#define sprintf(buf, format,...)
static DWORD get_cookie(substr_t host, substr_t path, DWORD flags, cookie_set_t *res)
__WINE_SERVER_LIST_INLINE void list_add_tail(struct list *list, struct list *elem)
GLenum GLuint GLenum GLsizei const GLchar * buf
static void cookie_set_to_string(const cookie_set_t *cookie_set, WCHAR *str)
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
static BOOL cookie_match_path(cookie_container_t *container, substr_t path)
static void replace_cookie(cookie_container_t *container, cookie_t *new_cookie)
_In_ HANDLE _In_ DWORD _In_ DWORD _Inout_opt_ LPOVERLAPPED _In_opt_ LPTRANSMIT_FILE_BUFFERS _In_ DWORD dwReserved
struct _cookie_domain_t * domain
struct _cookie_domain_t * parent
BOOL WINAPI ReadUrlCacheEntryStream(IN HANDLE hUrlCacheStream, IN DWORD dwLocation, IN OUT LPVOID lpBuffer, IN OUT LPDWORD lpdwLen, IN DWORD dwReserved)
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
static cookie_domain_t * get_cookie_domain(substr_t domain, BOOL create)
DWORD WINAPI InternetSetCookieExA(LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData, DWORD dwFlags, DWORD_PTR dwReserved)
BOOL WINAPI InternetSetPerSiteCookieDecisionA(LPCSTR pchHostName, DWORD dwDecision)
static BOOL save_persistent_cookie(cookie_container_t *container)
DWORD get_cookie_header(const WCHAR *host, const WCHAR *path, WCHAR **ret)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
static void delete_cookie(cookie_t *cookie)
static WCHAR * heap_strdupAtoW(const char *str)
static CRITICAL_SECTION cookie_cs
static cookie_t * find_cookie(cookie_container_t *container, substr_t name)
static struct list domain_list
__WINE_SERVER_LIST_INLINE void list_remove(struct list *elem)
BOOL WINAPI GetUserNameW(LPWSTR lpszName, LPDWORD lpSize)
BOOL WINAPI InternetEnumPerSiteCookieDecisionW(LPWSTR pszSiteName, ULONG *pcSiteNameSize, ULONG *pdwDecision, ULONG dwIndex)
LONG WINAPI CompareFileTime(IN CONST FILETIME *lpFileTime1, IN CONST FILETIME *lpFileTime2)
BOOL WINAPI UnlockUrlCacheEntryStream(IN HANDLE hUrlCacheStream, IN DWORD dwReserved)
_CONST_RETURN wchar_t *__cdecl wcschr(_In_z_ const wchar_t *_Str, wchar_t _Ch)
BOOL WINAPI CommitUrlCacheEntryW(LPCWSTR lpszUrlName, LPCWSTR lpszLocalFileName, FILETIME ExpireTime, FILETIME LastModifiedTime, DWORD CacheEntryType, LPWSTR lpHeaderInfo, DWORD dwHeaderSize, LPCWSTR lpszFileExtension, LPCWSTR lpszOriginalUrl)
HANDLE WINAPI RetrieveUrlCacheEntryStreamW(LPCWSTR lpszUrlName, LPINTERNET_CACHE_ENTRY_INFOW lpCacheEntryInfo, LPDWORD lpdwCacheEntryInfoBufferSize, BOOL fRandomRead, DWORD dwReserved)
BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName, LPCSTR lpCookieData)
static char * heap_strdupWtoA(const WCHAR *str)
BOOL WINAPI InternetEnumPerSiteCookieDecisionA(LPSTR pszSiteName, ULONG *pcSiteNameSize, ULONG *pdwDecision, ULONG dwIndex)
static WCHAR * create_cookie_url(substr_t domain, substr_t path, substr_t *ret_path)
BOOL WINAPI InternetGetCookieA(const char *url, const char *name, char *data, DWORD *size)
BOOL WINAPI InternetSetCookieW(const WCHAR *url, const WCHAR *name, const WCHAR *data)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
static BOOL cookie_parse_url(const WCHAR *url, substr_t *host, substr_t *path)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
#define memcpy(s1, s2, n)
GLsizei const GLfloat * value
DWORD set_cookie(substr_t domain, substr_t path, substr_t name, substr_t data, DWORD flags)
LIST_ENTRY ProcessLocksList
static DWORD LPSTR PDWORD lpdwSize
static void add_cookie(cookie_container_t *container, cookie_t *new_cookie)
__WINE_SERVER_LIST_INLINE int list_empty(const struct list *list)
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
struct _cookie_container_t cookie_container_t
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
__WINE_SERVER_LIST_INLINE void list_add_before(struct list *elem, struct list *to_add)
#define ERROR_INVALID_OPERATION
char * strchr(const char *String, int ch)
static BOOL load_persistent_cookie(substr_t domain, substr_t path)
BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwFlags, URL_COMPONENTSW *lpUC)
__WINE_SERVER_LIST_INLINE void list_init(struct list *list)
#define ERROR_INVALID_NAME
static CRITICAL_SECTION_DEBUG cookie_cs_debug
static substr_t substr(const WCHAR *str, size_t len)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
struct _cookie_container_t * container
#define INTERNET_COOKIE_HTTPONLY
BOOL WINAPI InternetTimeToSystemTimeW(LPCWSTR string, SYSTEMTIME *time, DWORD reserved)
BOOL WINAPI InternetGetPerSiteCookieDecisionA(LPCSTR pwchHostName, ULONG *pResult)
static const struct access_res create[16]
static cookie_t * alloc_cookie(substr_t name, substr_t data, FILETIME expiry, FILETIME create_time, DWORD flags)
BOOL WINAPI InternetSetPerSiteCookieDecisionW(LPCWSTR pchHostName, DWORD dwDecision)
static BOOL heap_free(void *mem)
BOOL WINAPI DeleteUrlCacheEntryW(LPCWSTR lpszUrlName)
#define ERROR_INSUFFICIENT_BUFFER
GLuint const GLchar * name