40 #define RESPONSE_TIMEOUT 30 92 0, 0, { (
DWORD_PTR)(__FILE__
": cookie_cs") }
105 subdomain_ptr = *
ptr ==
'.' ?
ptr+1 :
ptr;
107 current_domain =
NULL;
111 current_domain = iter;
116 if(!current_domain) {
120 current_domain =
heap_alloc(
sizeof(*current_domain));
125 if(!current_domain->
domain) {
132 current_domain->
parent = prev_domain;
140 return current_domain;
142 prev_domain = current_domain;
152 static const WCHAR cookie_prefix[] = {
'C',
'o',
'o',
'k',
'i',
'e',
':'};
164 memcpy(
url, cookie_prefix,
sizeof(cookie_prefix));
198 return cookie_container;
204 cookie_container =
heap_alloc(
sizeof(*cookie_container));
205 if(!cookie_container)
214 cookie_container->
domain = cookie_domain;
220 return cookie_container;
225 return cookie_container;
241 new_cookie = heap_alloc_zero(
sizeof(*new_cookie));
245 new_cookie->
expiry = expiry;
306 char *
str =
NULL, *pbeg, *pend;
312 if(!cookie_container)
338 pend =
strchr(pbeg,
'\n');
345 pend =
strchr(pbeg,
'\n');
351 pbeg =
strchr(pend+1,
'\n');
391 static const WCHAR txtW[] = {
't',
'x',
't',0};
397 char buf[64], *dyn_buf;
438 if(!dyn_buf || !
WriteFile(cookie_handle, dyn_buf,
strlen(dyn_buf), &bytes_written,
NULL)) {
444 if(!
WriteFile(cookie_handle,
"\n", 1, &bytes_written,
NULL)) {
450 if(!dyn_buf || !
WriteFile(cookie_handle, dyn_buf,
strlen(dyn_buf), &bytes_written,
NULL)) {
456 if(!
WriteFile(cookie_handle,
"\n", 1, &bytes_written,
NULL)) {
462 if(!dyn_buf || !
WriteFile(cookie_handle, dyn_buf,
strlen(dyn_buf), &bytes_written,
NULL)) {
475 if(!dyn_buf || !
WriteFile(cookie_handle, dyn_buf,
strlen(dyn_buf), &bytes_written,
NULL)) {
493 ERR(
"error saving cookie file\n");
532 static const WCHAR empty_path[] = {
'/',0 };
542 while(
p >
host.str &&
p[-1] !=
'.')
p--;
543 while(
p !=
host.str) {
545 while(
p >
host.str &&
p[-1] !=
'.')
p--;
546 if(
p ==
host.str)
break;
556 while(
p >
path.str &&
p[-1] !=
'/')
p--;
557 }
while(
p !=
path.str);
578 TRACE(
"Found expired cookie. deleting\n");
591 }
else if(
res->cnt ==
res->size) {
595 res->cookies = new_cookies;
603 res->string_len += 2;
604 res->cookies[
res->cnt++] = cookie_iter;
607 if(*cookie_iter->
data)
621 for(
i=0;
i<cookie_set->
cnt;
i++) {
648 static const WCHAR cookieW[] = {
'C',
'o',
'o',
'k',
'i',
'e',
':',
' '};
734 TRACE(
"(%s, %s, %p, %p, %x, %p)\n",
debugstr_w(lpszUrl),
debugstr_w(lpszCookieName), lpCookieData,
lpdwSize,
flags,
reserved);
870 if(!
domain.len || *
domain.str ==
'.' || !full_domain.
len || *full_domain.
str ==
'.') {
894 if (!
domain || !full_domain) {
914 const WCHAR *end_ptr;
922 memset(&expiry,0,
sizeof(expiry));
934 static const WCHAR szDomain[] = {
'd',
'o',
'm',
'a',
'i',
'n',
'='};
935 static const WCHAR szPath[] = {
'p',
'a',
't',
'h',
'='};
936 static const WCHAR szExpires[] = {
'e',
'x',
'p',
'i',
'r',
'e',
's',
'='};
937 static const WCHAR szSecure[] = {
's',
'e',
'c',
'u',
'r',
'e'};
938 static const WCHAR szHttpOnly[] = {
'h',
't',
't',
'p',
'o',
'n',
'l',
'y'};
939 static const WCHAR szVersion[] = {
'v',
'e',
'r',
's',
'i',
'o',
'n',
'='};
940 static const WCHAR max_ageW[] = {
'm',
'a',
'x',
'-',
'a',
'g',
'e',
'='};
984 TRACE(
"Cookie already expired.\n");
991 FIXME(
"secure not handled\n");
996 WARN(
"HTTP only cookie added without INTERNET_COOKIE_HTTPONLY flag\n");
1008 WARN(
"Max-Age ignored\n");
1009 }
else if(
data.len) {
1029 update_persistent =
TRUE;
1033 WARN(
"An attempt to override httponly cookie\n");
1040 update_persistent =
TRUE;
1086 if (!lpszUrl || !lpCookieData)
1095 if (!lpszCookieName) {
1207 FIXME(
"(%s, %p, %p, 0x%08x) stub\n",
1208 debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
1225 FIXME(
"(%s, %p, %p, 0x%08x) stub\n",
1226 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)
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
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)
GLenum GLuint GLenum GLsizei const GLchar * buf
BOOL WINAPI InternetClearAllPerSiteCookieDecisions(VOID)
GLsizei const GLchar ** path
GLdouble GLdouble GLdouble r
WINE_UNICODE_INLINE WCHAR * strchrW(const WCHAR *str, WCHAR ch)
static const WCHAR rootW[]
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
#define strncmpiW(s1, s2, n)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
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)
static void cookie_set_to_string(const cookie_set_t *cookie_set, WCHAR *str)
#define LIST_FOR_EACH_ENTRY(elem, 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
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)
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)
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
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)
DWORD set_cookie(substr_t domain, substr_t path, substr_t name, substr_t data, DWORD flags)
LIST_ENTRY ProcessLocksList
GLsizei const GLfloat * value
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)
static const WCHAR szExpires[]
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)
__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
WINE_UNICODE_INLINE WCHAR * memchrW(const WCHAR *ptr, WCHAR ch, size_t n)
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)
void user(int argc, const char *argv[])
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