diff --git a/uppsrc/Core/Http.cpp b/uppsrc/Core/Http.cpp index af820985d..2839070d2 100644 --- a/uppsrc/Core/Http.cpp +++ b/uppsrc/Core/Http.cpp @@ -659,13 +659,11 @@ void HttpRequest::Finish() #endif } Close(); - if(cookies) - CopyCookies(); + CopyCookies(); if(status_code == 401 && !IsNull(username)) { String authenticate = header["www-authenticate"]; if(authenticate.GetCount() && redirect_count++ < max_redirects) { LLOG("HTTP auth digest"); - CopyCookies(); Digest(CalculateDigest(authenticate)); Start(); return; @@ -676,7 +674,6 @@ void HttpRequest::Finish() if(url.GetCount() && redirect_count++ < max_redirects) { LLOG("--- HTTP redirect " << url); Url(url); - CopyCookies(); Start(); retry_count = 0; return; diff --git a/uppsrc/Core/Inet.h b/uppsrc/Core/Inet.h index 76332793d..b3cd977b3 100644 --- a/uppsrc/Core/Inet.h +++ b/uppsrc/Core/Inet.h @@ -343,7 +343,6 @@ class HttpRequest : public TcpSocket { void ReadingChunkHeader(); void Finish(); bool IsRequestTimeout(); - void CopyCookies(); void HttpError(const char *s); @@ -390,8 +389,6 @@ public: HttpRequest& AddHeaders(const String& h) { request_headers.Cat(h); return *this; } HttpRequest& Header(const char *id, const String& data); HttpRequest& Cookie(const String& cookie) { return Header("Cookie", cookie); } - - HttpRequest& Cookies(bool b = true) { cookies = b; } HttpRequest& StdHeaders(bool sh) { std_headers = sh; return *this; } HttpRequest& NoStdHeaders() { return StdHeaders(false); } diff --git a/uppsrc/Core/SSL/InitExit.icpp b/uppsrc/Core/SSL/InitExit.icpp index bc02c647d..a90f27710 100644 --- a/uppsrc/Core/SSL/InitExit.icpp +++ b/uppsrc/Core/SSL/InitExit.icpp @@ -1,101 +1,101 @@ -#include "SSL.h" - -#define LLOG(x) // DLOG(x) - -NAMESPACE_UPP - -static int64 UPP_SSL_alloc = 0; - -static void *SslAlloc(size_t size) -{ - LLOG("Alloc " << size); - size_t alloc = size + sizeof(int64); - int64 *aptr = (int64 *)MemoryAllocSz(alloc); - *aptr++ = (int64)alloc; - LLOG("UPP_SSL_MALLOC(" << (int64)size << ", alloc " << alloc << ") -> " << FormatIntHex(aptr) << ", total = " << UPP_SSL_alloc); - return aptr; -} - -static void SslFree(void *ptr) -{ - if(!ptr) - return; - int64 *aptr = (int64 *)ptr - 1; - UPP_SSL_alloc -= *aptr; - LLOG("UPP_SSL_FREE(" << ptr << ", alloc " << *aptr << "), total = " << UPP_SSL_alloc); - MemoryFree(aptr); -} - -static void *SslRealloc(void *ptr, size_t size) -{ - if(!ptr) - return NULL; - int64 *aptr = (int64 *)ptr - 1; - if((int64)(size + sizeof(int64)) <= *aptr) { - LLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int64)size << ", alloc " << *aptr << ") -> keep same block"); - return ptr; - } - size_t newalloc = size + sizeof(int64); - int64 *newaptr = (int64 *)MemoryAllocSz(newalloc); - if(!newaptr) { - LLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int64)size << ", alloc " << newalloc << ") -> fail"); - return NULL; - } - *newaptr++ = newalloc; - memcpy(newaptr, ptr, min(*aptr - sizeof(int64), size)); - UPP_SSL_alloc += newalloc - *aptr; - LLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int64)size << ", alloc " << newalloc << ") -> " - << FormatIntHex(newaptr) << ", total = " << UPP_SSL_alloc); - MemoryFree(aptr); - return newaptr; -} - -void TcpSocketInit(); - -INITBLOCK -{ - LLOG("SSL init"); - TcpSocketInit(); - MemoryIgnoreLeaksBlock __; - CRYPTO_set_mem_functions(SslAlloc, SslRealloc, SslFree); - SSL_library_init(); - SSL_load_error_strings(); -} - -EXITBLOCK -{ - CONF_modules_unload(1); - EVP_cleanup(); - ENGINE_cleanup(); - CRYPTO_cleanup_all_ex_data(); - ERR_remove_state(0); - ERR_free_strings(); -} - -#ifdef _MULTITHREADED - -static thread__ bool sThreadInit; -static thread__ void (*sPrevExit)(); - -static void sslExitThread() -{ - ERR_remove_state(0); - if(sPrevExit) - (*sPrevExit)(); -} - -void SslInitThread() -{ - if(sThreadInit || Thread::IsMain()) - return; - sThreadInit = true; - sPrevExit = Thread::AtExit(sslExitThread); -} - -#else - -void SslInitThread() {} - -#endif - -END_UPP_NAMESPACE +#include "SSL.h" + +#define LLOG(x) // DLOG(x) + +NAMESPACE_UPP + +static int64 UPP_SSL_alloc = 0; + +static void *SslAlloc(size_t size) +{ + LLOG("Alloc " << size); + size_t alloc = size + sizeof(int64); + int64 *aptr = (int64 *)MemoryAllocSz(alloc); + *aptr++ = (int64)alloc; + LLOG("UPP_SSL_MALLOC(" << (int64)size << ", alloc " << alloc << ") -> " << FormatIntHex(aptr) << ", total = " << UPP_SSL_alloc); + return aptr; +} + +static void SslFree(void *ptr) +{ + if(!ptr) + return; + int64 *aptr = (int64 *)ptr - 1; + UPP_SSL_alloc -= *aptr; + LLOG("UPP_SSL_FREE(" << ptr << ", alloc " << *aptr << "), total = " << UPP_SSL_alloc); + MemoryFree(aptr); +} + +static void *SslRealloc(void *ptr, size_t size) +{ + if(!ptr) + return NULL; + int64 *aptr = (int64 *)ptr - 1; + if((int64)(size + sizeof(int64)) <= *aptr) { + LLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int64)size << ", alloc " << *aptr << ") -> keep same block"); + return ptr; + } + size_t newalloc = size + sizeof(int64); + int64 *newaptr = (int64 *)MemoryAllocSz(newalloc); + if(!newaptr) { + LLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int64)size << ", alloc " << newalloc << ") -> fail"); + return NULL; + } + *newaptr++ = newalloc; + memcpy(newaptr, ptr, min((int)(*aptr - sizeof(int64)), size)); + UPP_SSL_alloc += newalloc - *aptr; + LLOG("UPP_SSL_REALLOC(" << ptr << ", " << (int64)size << ", alloc " << newalloc << ") -> " + << FormatIntHex(newaptr) << ", total = " << UPP_SSL_alloc); + MemoryFree(aptr); + return newaptr; +} + +void TcpSocketInit(); + +INITBLOCK +{ + LLOG("SSL init"); + TcpSocketInit(); + MemoryIgnoreLeaksBlock __; + CRYPTO_set_mem_functions(SslAlloc, SslRealloc, SslFree); + SSL_library_init(); + SSL_load_error_strings(); +} + +EXITBLOCK +{ + CONF_modules_unload(1); + EVP_cleanup(); + ENGINE_cleanup(); + CRYPTO_cleanup_all_ex_data(); + ERR_remove_state(0); + ERR_free_strings(); +} + +#ifdef _MULTITHREADED + +static thread__ bool sThreadInit; +static thread__ void (*sPrevExit)(); + +static void sslExitThread() +{ + ERR_remove_state(0); + if(sPrevExit) + (*sPrevExit)(); +} + +void SslInitThread() +{ + if(sThreadInit || Thread::IsMain()) + return; + sThreadInit = true; + sPrevExit = Thread::AtExit(sslExitThread); +} + +#else + +void SslInitThread() {} + +#endif + +END_UPP_NAMESPACE