|
@@ -513,10 +513,35 @@ curl_slist* IBBS2chProxyPoster::prepareCurlHandle(BBS2chProxyHttpHeaders &header
|
|
{
|
|
{
|
|
CURL *curl = connectionDelegate->curl;
|
|
CURL *curl = connectionDelegate->curl;
|
|
if (_manageCookies) {
|
|
if (_manageCookies) {
|
|
- log_printf(1, "Cookies are managed by proxy2ch, all existing \"Cookie: \" headers are ignored.\n");
|
|
|
|
|
|
+ log_printf(1, "Cookies are managed by proxy2ch, most of existing \"Cookie: \" headers are ignored.\n");
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); //enable cookie engine explicitly
|
|
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, ""); //enable cookie engine explicitly
|
|
curl_easy_setopt(curl, CURLOPT_COOKIELIST, "ALL"); //erase all cookies explicitly
|
|
curl_easy_setopt(curl, CURLOPT_COOKIELIST, "ALL"); //erase all cookies explicitly
|
|
- headers.remove("Cookie");
|
|
|
|
|
|
+ if (headers.has("Cookie")) {
|
|
|
|
+ const std::string &value = headers.getEntry("Cookie")->getValue();
|
|
|
|
+ std::vector<std::string> list;
|
|
|
|
+ size_t offset = 0;
|
|
|
|
+ while (1) {
|
|
|
|
+ size_t pos = value.find("; ", offset);
|
|
|
|
+ if (pos == std::string::npos) {
|
|
|
|
+ list.push_back(value.substr(offset));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ list.push_back(value.substr(offset, pos - offset));
|
|
|
|
+ offset = pos + 2;
|
|
|
|
+ }
|
|
|
|
+ std::string newCookie;
|
|
|
|
+ for (std::vector<std::string>::iterator it = list.begin(); it != list.end(); ++it) {
|
|
|
|
+ size_t pos = it->find('=');
|
|
|
|
+ if (pos == std::string::npos) continue;
|
|
|
|
+ std::string name = it->substr(0, pos);
|
|
|
|
+ if (name == "DMDM" || name == "MDMD" || name == "sid") {
|
|
|
|
+ if (newCookie.size()) newCookie += "; ";
|
|
|
|
+ newCookie += *it;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (newCookie.size()) curl_easy_setopt(curl, CURLOPT_COOKIE, newCookie.c_str());
|
|
|
|
+ headers.remove("Cookie");
|
|
|
|
+ }
|
|
BBS2chProxyKeyManager::CookieJar &jar = BBS2chProxyConnection::keyManager.getCookieJar(_userAgentForRequest);
|
|
BBS2chProxyKeyManager::CookieJar &jar = BBS2chProxyConnection::keyManager.getCookieJar(_userAgentForRequest);
|
|
jar.lock();
|
|
jar.lock();
|
|
std::vector<BBS2chProxyKeyManager::Cookie> &list = jar.getList();
|
|
std::vector<BBS2chProxyKeyManager::Cookie> &list = jar.getList();
|