diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-09-10 04:27:14 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2014-09-10 04:27:14 +0000 |
commit | ed4d2e70f154be0badfcc44afa04c0d8e984f03d (patch) | |
tree | 8debabb11e2080690ff5f4ba18c55b6d16ad8b98 /protocols/VKontakte/src/vk_queue.cpp | |
parent | 18a97b56e7042d69af69f0f5bf4c13436675ebc4 (diff) |
VKontakte: redesign PARAM structure attempt 2, redesign AsyncHttpRequest structure
git-svn-id: http://svn.miranda-ng.org/main/trunk@10415 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src/vk_queue.cpp')
-rw-r--r-- | protocols/VKontakte/src/vk_queue.cpp | 61 |
1 files changed, 24 insertions, 37 deletions
diff --git a/protocols/VKontakte/src/vk_queue.cpp b/protocols/VKontakte/src/vk_queue.cpp index 5b9fc4b282..8240b45c84 100644 --- a/protocols/VKontakte/src/vk_queue.cpp +++ b/protocols/VKontakte/src/vk_queue.cpp @@ -35,7 +35,18 @@ void CVkProto::UninitQueue() void CVkProto::ExecuteRequest(AsyncHttpRequest *pReq)
{
LBL_Restart:
- pReq->szUrl = pReq->m_szUrl.GetBuffer();
+ if (pReq->m_szParam.IsEmpty())
+ pReq->szUrl = pReq->m_szUrl.GetBuffer();
+ else if (pReq->requestType == REQUEST_GET){
+ CMStringA str(FORMAT, "%s?%s", pReq->m_szUrl, pReq->m_szParam);
+ pReq->szUrl = str.GetBuffer();
+ }
+ else{
+ pReq->szUrl = pReq->m_szUrl.GetBuffer();
+ pReq->pData = pReq->m_szParam.GetBuffer();
+ pReq->dataLength = pReq->m_szParam.GetLength();
+ }
+
NETLIBHTTPREQUEST *reply = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)m_hNetlibUser, (LPARAM)pReq);
if (reply != NULL) {
if (pReq->m_pFunc != NULL)
@@ -113,52 +124,28 @@ void CVkProto::WorkerThread(void*) AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const INT_PARAM ¶m)
{
- if (param.rtType == reqGET){
- CMStringA &s = pReq->m_szUrl;
- s.AppendFormat("%c%s=%i", pReq->m_bHasGParams ? '&' : '?', param.szName, param.iValue);
- pReq->m_bHasGParams = true;
- }
- else {
- CMStringA s = pReq->pData;
- s.AppendFormat("%s%s=%i", pReq->m_bHasPParams ? "&" : "?", param.szName, param.iValue);
- pReq->pData = mir_strdup(s);
- pReq->dataLength = s.GetLength();
- pReq->m_bHasPParams = true;
- }
+ CMStringA &s = pReq->m_szParam;
+ if (!s.IsEmpty())
+ s.AppendChar('&');
+ s.AppendFormat("%s=%i", param.szName, param.iValue);
return pReq;
}
AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const CHAR_PARAM ¶m)
{
- if (param.rtType == reqGET){
- CMStringA &s = pReq->m_szUrl;
- s.AppendFormat("%c%s=%s", pReq->m_bHasGParams ? '&' : '?', param.szName, ptrA(mir_urlEncode(param.szValue)));
- pReq->m_bHasGParams = true;
- }
- else {
- CMStringA s = pReq->pData;
- s.AppendFormat("%s%s=%s", pReq->m_bHasPParams ? "&" : "", param.szName, ptrA(mir_urlEncode(param.szValue)));
- pReq->pData = mir_strdup(s);
- pReq->dataLength = s.GetLength();
- pReq->m_bHasPParams = true;
- }
+ CMStringA &s = pReq->m_szParam;
+ if (!s.IsEmpty())
+ s.AppendChar('&');
+ s.AppendFormat("%s=%s", param.szName, ptrA(mir_urlEncode(param.szValue)));
return pReq;
}
AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const TCHAR_PARAM ¶m)
{
ptrA szValue(mir_utf8encodeT(param.tszValue));
- if (param.rtType == reqGET){
- CMStringA &s = pReq->m_szUrl;
- s.AppendFormat("%c%s=%s", pReq->m_bHasGParams ? '&' : '?', param.szName, ptrA(mir_urlEncode(szValue)));
- pReq->m_bHasGParams = true;
- }
- else{
- CMStringA s = pReq->pData;
- s.AppendFormat("%s%s=%s", pReq->m_bHasGParams ? "&" : "?", param.szName, ptrA(mir_urlEncode(szValue)));
- pReq->pData = mir_strdup(s);
- pReq->dataLength = s.GetLength();
- pReq->m_bHasPParams = true;
- }
+ CMStringA &s = pReq->m_szParam;
+ if (!s.IsEmpty())
+ s.AppendChar('&');
+ s.AppendFormat("%s=%s", param.szName, ptrA(mir_urlEncode(szValue)));
return pReq;
}
|