blob: 61d9754ec0160f124d982664e24b2e3bb887e3e4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
#include "common.h"
class SkypeResponseDelegate
{
private:
CSkypeProto *proto;
SkypeResponseCallback responseCallback;
public:
SkypeResponseDelegate(CSkypeProto *proto, SkypeResponseCallback responseCallback)
: proto(proto), responseCallback(responseCallback) { }
void Invoke(const NETLIBHTTPREQUEST *response)
{
(proto->*(responseCallback))(response);
}
};
static void SkypeHttpResponse(const NETLIBHTTPREQUEST *response, void *arg)
{
((SkypeResponseDelegate*)arg)->Invoke(response);
}
void CSkypeProto::PushRequest(HttpRequest *request, SkypeResponseCallback response)
{
if (!cookies.empty())
{
CMStringA allCookies;
for (std::map<std::string, std::string>::iterator cookie = cookies.begin(); cookie != cookies.end(); ++cookie)
allCookies.AppendFormat("%s=%s; ", cookie->first.c_str(), cookie->second.c_str());
request->Headers << CHAR_VALUE("Set-Cookie", allCookies);
}
if (response == NULL)
{
requestQueue->Push(request);
return;
}
SkypeResponseDelegate *delegate = new SkypeResponseDelegate(this, response);
requestQueue->Push(request, SkypeHttpResponse, delegate);
}
|