summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2015-02-17 21:41:12 +0000
committerRobert Pösel <robyer@seznam.cz>2015-02-17 21:41:12 +0000
commitbe0760ef05bfac420dc4ea242356bc5d14029081 (patch)
tree8a39166b323063349f415a1623b506fff1f2f2c4 /protocols/FacebookRM
parent712e35eb4d8f1664b3d8e696b029e532cd928cee (diff)
Facebook: Fix setting post request headers
Also update some request params but that's not important or needed. git-svn-id: http://svn.miranda-ng.org/main/trunk@12173 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/communication.cpp35
-rw-r--r--protocols/FacebookRM/src/proto.cpp5
2 files changed, 26 insertions, 14 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 976f8263a6..2c84a18b5b 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -36,23 +36,17 @@ http::response facebook_client::flap(RequestType request_type, std::string *post
return resp;
}
+ // Prepare the request
NETLIBHTTPREQUEST nlhr = { sizeof(NETLIBHTTPREQUEST) };
+ // Set request URL
std::string url = HTTP_PROTO_SECURE + choose_server(request_type) + choose_action(request_type, get_data);
-
if (!parent->m_locale.empty())
url += "&locale=" + parent->m_locale;
-
+
nlhr.szUrl = (char*)url.c_str();
- nlhr.flags = NLHRF_HTTP11 | NLHRF_SSL;
- nlhr.headers = get_request_headers(nlhr.requestType, &nlhr.headersCount);
-
-#ifdef _DEBUG
- nlhr.flags |= NLHRF_DUMPASTEXT;
-#else
- nlhr.flags |= NLHRF_NODUMP;
-#endif
+ // Set timeout (bigger for channel request)
switch (request_type) {
case REQUEST_MESSAGES_RECEIVE:
nlhr.timeout = 1000 * 65;
@@ -63,6 +57,7 @@ http::response facebook_client::flap(RequestType request_type, std::string *post
break;
}
+ // Set request type (GET/POST) and eventually also POST data
if (post_data != NULL) {
nlhr.requestType = REQUEST_POST;
nlhr.pData = (char*)(*post_data).c_str();
@@ -71,8 +66,19 @@ http::response facebook_client::flap(RequestType request_type, std::string *post
nlhr.requestType = REQUEST_GET;
}
- parent->debugLogA("@@@ Sending request to '%s'", nlhr.szUrl);
+ // Set headers - it depends on requestType so it must be after setting that
+ nlhr.headers = get_request_headers(nlhr.requestType, &nlhr.headersCount);
+ // Set flags
+ nlhr.flags = NLHRF_HTTP11 | NLHRF_SSL;
+
+#ifdef _DEBUG
+ nlhr.flags |= NLHRF_DUMPASTEXT;
+#else
+ nlhr.flags |= NLHRF_NODUMP;
+#endif
+
+ // Set persistent connection (or not)
switch (request_type) {
case REQUEST_LOGIN:
nlhr.nlc = NULL;
@@ -90,11 +96,15 @@ http::response facebook_client::flap(RequestType request_type, std::string *post
break;
}
- NETLIBHTTPREQUEST* pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)handle_, (LPARAM)&nlhr);
+ parent->debugLogA("@@@ Sending request to '%s'", nlhr.szUrl);
+
+ // Send the request
+ NETLIBHTTPREQUEST *pnlhr = (NETLIBHTTPREQUEST*)CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM)handle_, (LPARAM)&nlhr);
mir_free(nlhr.headers[3].szValue);
mir_free(nlhr.headers);
+ // Remember the persistent connection handle (or not)
switch (request_type) {
case REQUEST_LOGIN:
case REQUEST_SETUP_MACHINE:
@@ -110,6 +120,7 @@ http::response facebook_client::flap(RequestType request_type, std::string *post
break;
}
+ // Check and copy response data
if (pnlhr != NULL) {
parent->debugLogA("@@@ Got response with code %d", pnlhr->resultCode);
store_headers(&resp, pnlhr->headers, pnlhr->headersCount);
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index b28a465de1..1e69fd0689 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -3,7 +3,7 @@
Facebook plugin for Miranda Instant Messenger
_____________________________________________
-Copyright © 2009-11 Michal Zelinka, 2011-15 Robert Pösel
+Copyright � 2009-11 Michal Zelinka, 2011-15 Robert P�sel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -921,9 +921,10 @@ void FacebookProto::ReadNotificationWorker(void *p)
return;
}
- std::string data = "seen=0&asyncSignal=&__dyn=&__req=a&alert_ids%5B0%5D=" + utils::url::encode(*id);
+ std::string data = "seen=true&asyncSignal=&__dyn=&__rev=&__req=&alert_ids%5B0%5D=" + utils::url::encode(*id);
data += "&fb_dtsg=" + facy.dtsg_;
data += "&__user=" + facy.self_.user_id;
+ data += "&ttstamp=" + facy.ttstamp();
facy.flap(REQUEST_NOTIFICATIONS_READ, NULL, &data);