summaryrefslogtreecommitdiff
path: root/protocols/VKontakte/src/vk_thread.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-13 11:54:13 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-13 11:54:13 +0000
commitd04a944cedf1e405ffa8879ea6ae139f675b8616 (patch)
tree01dfc58c103c27301cb836d434b66d6063d11302 /protocols/VKontakte/src/vk_thread.cpp
parent27c56000557f31b16358107754515e409b68a71b (diff)
VK: quick-n-dirty cookie parser
git-svn-id: http://svn.miranda-ng.org/main/trunk@6488 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_thread.cpp')
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index caaa8d8e91..876454439a 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -82,12 +82,12 @@ int CVkProto::SetServerStatus(int iStatus)
/////////////////////////////////////////////////////////////////////////////////////////
-extern CMStringA loginCookie;
-
static char VK_TOKEN_BEG[] = "access_token=";
void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, void*)
{
+ GrabCookies(reply);
+
if (reply->resultCode == 302) { // manual redirect
LPCSTR pszLocation = findHeader(reply, "Location");
if (pszLocation) {
@@ -118,10 +118,10 @@ void CVkProto::OnOAuthAuthorize(NETLIBHTTPREQUEST *reply, void*)
pReq->AddHeader("Referer", m_prevUrl);
pReq->Redirect(reply);
if (pReq->szUrl) {
- if ( strstr(pReq->szUrl, "login.vk.com"))
- pReq->AddHeader("Cookie", loginCookie);
+ ApplyCookies(pReq);
m_prevUrl = pReq->szUrl;
}
+
PushAsyncHttpRequest(pReq);
}
}
@@ -148,8 +148,11 @@ LBL_NoForm:
CMStringA szAction;
CMStringA szBody = AutoFillForm(reply->pData, szAction);
- if (szAction.IsEmpty() || szBody.IsEmpty())
- goto LBL_NoForm;
+ if (szAction.IsEmpty() || szBody.IsEmpty()) {
+ if (m_prevError)
+ goto LBL_NoForm;
+ m_prevError = true;
+ }
AsyncHttpRequest *pReq = new AsyncHttpRequest();
pReq->requestType = REQUEST_POST;
@@ -160,6 +163,7 @@ LBL_NoForm:
pReq->m_pFunc = &CVkProto::OnOAuthAuthorize;
pReq->AddHeader("Content-Type", "application/x-www-form-urlencoded");
pReq->Redirect(reply);
+ ApplyCookies(pReq);
PushAsyncHttpRequest(pReq);
}