summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_netlib.h7
-rw-r--r--libs/win32/mir_app.libbin290506 -> 290758 bytes
-rw-r--r--libs/win64/mir_app.libbin290214 -> 290468 bytes
-rw-r--r--plugins/HTTPServer/src/GuiElements.cpp2
-rw-r--r--plugins/MirLua/src/Modules/m_http.cpp5
-rw-r--r--plugins/PackUpdater/Src/Utils.cpp3
-rw-r--r--plugins/PasteIt/src/PasteToWeb.cpp3
-rw-r--r--plugins/PluginUpdater/src/Utils.cpp3
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.cpp7
-rw-r--r--plugins/SendScreenshotPlus/src/CSend.h16
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp6
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h6
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp2
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_imgur.h1
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp7
-rw-r--r--plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h1
-rw-r--r--plugins/SmileyAdd/src/download.cpp3
-rw-r--r--protocols/CloudFile/src/http_request.h15
-rw-r--r--protocols/CurrencyRates/src/HTTPSession.cpp3
-rw-r--r--protocols/Facebook/src/avatars.cpp3
-rw-r--r--protocols/Facebook/src/server.cpp3
-rw-r--r--protocols/Gadu-Gadu/src/avatar.cpp9
-rw-r--r--protocols/Gadu-Gadu/src/oauth.cpp9
-rw-r--r--protocols/GmailNotifier/src/check.cpp8
-rw-r--r--protocols/JabberG/src/jabber_file.cpp9
-rw-r--r--protocols/JabberG/src/jabber_ft.cpp3
-rw-r--r--protocols/JabberG/src/jabber_util.cpp3
-rw-r--r--protocols/MinecraftDynmap/src/communication.cpp3
-rw-r--r--protocols/NewsAggregator/Src/Utils.cpp6
-rw-r--r--protocols/Non-IM Contact/src/http.cpp3
-rw-r--r--protocols/Tox/src/http_request.h15
-rw-r--r--protocols/Twitter/src/utility.cpp3
-rw-r--r--protocols/VKontakte/src/misc.cpp3
-rw-r--r--protocols/VKontakte/src/vk_captcha.cpp3
-rw-r--r--protocols/VKontakte/src/vk_pollserver.cpp3
-rw-r--r--protocols/Weather/src/weather_http.cpp3
-rw-r--r--protocols/WebView/src/webview_getdata.cpp3
-rw-r--r--protocols/WhatsApp/src/avatars.cpp3
-rw-r--r--protocols/WhatsApp/src/utils.cpp3
-rw-r--r--src/mir_app/src/MHttpRequest.cpp7
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/netlib_autoproxy.cpp2
-rw-r--r--src/mir_app/src/netlib_openconn.cpp3
-rw-r--r--src/mir_app/src/netlib_websocket.cpp2
45 files changed, 88 insertions, 118 deletions
diff --git a/include/m_netlib.h b/include/m_netlib.h
index 85e91f3d90..afc4493c7b 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -451,10 +451,10 @@ struct MIR_APP_EXPORT MHttpHeaders : public OBJLIST<MHttpHeader>
struct MIR_APP_EXPORT MHttpRequest : public MHttpHeaders, public MNonCopyable, public MZeroedObject
{
- MHttpRequest();
+ MHttpRequest(int type);
~MHttpRequest();
- int requestType = REQUEST_GET; // a REQUEST_
+ int requestType; // a REQUEST_
uint32_t flags;
CMStringA m_szUrl, m_szParam;
HNETLIBCONN nlc;
@@ -516,7 +516,8 @@ template <class T>
class MTHttpRequest : public MHttpRequest
{
public:
- __forceinline MTHttpRequest()
+ __forceinline MTHttpRequest() :
+ MHttpRequest(REQUEST_GET)
{}
typedef void (T::*MTHttpRequestHandler)(MHttpResponse*, struct AsyncHttpRequest*);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 2d8394173c..dd079c065b 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index d2e9e3988b..873ddbcbb9 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/HTTPServer/src/GuiElements.cpp b/plugins/HTTPServer/src/GuiElements.cpp
index a3f02f86bb..4fc36e40f2 100644
--- a/plugins/HTTPServer/src/GuiElements.cpp
+++ b/plugins/HTTPServer/src/GuiElements.cpp
@@ -141,7 +141,7 @@ unsigned long GetExternIP(const char *szURL, const char *szPattern)
{
HCURSOR hPrevCursor = ::SetCursor(::LoadCursor(nullptr, IDC_WAIT));
- MHttpRequest nlhr;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_DUMPASTEXT;
nlhr.m_szUrl = szURL;
diff --git a/plugins/MirLua/src/Modules/m_http.cpp b/plugins/MirLua/src/Modules/m_http.cpp
index fcc0365078..bbad6165fb 100644
--- a/plugins/MirLua/src/Modules/m_http.cpp
+++ b/plugins/MirLua/src/Modules/m_http.cpp
@@ -4,7 +4,7 @@
static MHttpRequest* CreateRequest()
{
- MHttpRequest *request = new MHttpRequest();
+ MHttpRequest *request = new MHttpRequest(REQUEST_GET);
request->flags = NLHRF_HTTP11 | NLHRF_NODUMP;
return request;
}
@@ -269,9 +269,8 @@ static int request_Send(lua_State *L)
{
MHttpRequest *request = *(MHttpRequest**)luaL_checkudata(L, 1, MT_NETLIBHTTPREQUEST);
- MHttpRequest *newRequest = new MHttpRequest();
+ MHttpRequest *newRequest = new MHttpRequest(request->requestType);
newRequest->flags = request->flags;
- newRequest->requestType = request->requestType;
newRequest->m_szUrl = request->m_szUrl;
newRequest->m_szParam = request->m_szParam;
newRequest->timeout = request->timeout;
diff --git a/plugins/PackUpdater/Src/Utils.cpp b/plugins/PackUpdater/Src/Utils.cpp
index 6319ca47c0..7c3212388e 100644
--- a/plugins/PackUpdater/Src/Utils.cpp
+++ b/plugins/PackUpdater/Src/Utils.cpp
@@ -107,8 +107,7 @@ void LoadOptions()
BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
{
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_REDIRECT | NLHRF_DUMPASTEXT | NLHRF_HTTP11;
nlhr.m_szUrl = _T2A(tszURL);
nlhr.AddHeader("User-Agent", NETLIB_USER_AGENT);
diff --git a/plugins/PasteIt/src/PasteToWeb.cpp b/plugins/PasteIt/src/PasteToWeb.cpp
index 5fdfc7afec..cac74b80de 100644
--- a/plugins/PasteIt/src/PasteToWeb.cpp
+++ b/plugins/PasteIt/src/PasteToWeb.cpp
@@ -426,8 +426,7 @@ char *PasteToWeb::SendToWeb(char *url, std::map<std::string, std::string> &heade
WideCharToMultiByte(CP_UTF8, 0, content.c_str(), -1, contentBytes, cbLen, nullptr, nullptr);
--cbLen;
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_POST;
+ MHttpRequest nlhr(REQUEST_POST);
nlhr.flags = NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT | NLHPIF_HTTP11;
nlhr.m_szUrl = url;
nlhr.SetData(contentBytes, cbLen);
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index 4cc80eaec1..90921aaa13 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -145,9 +145,8 @@ int DownloadFile(FILEURL *pFileURL, HNETLIBCONN &nlc)
ptrA szUrl(mir_u2a(pFileURL->wszDownloadURL));
- MHttpRequest nlhr;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_PERSISTENT;
- nlhr.requestType = REQUEST_GET;
nlhr.nlc = nlc;
nlhr.m_szUrl = szUrl;
nlhr.AddHeader("User-Agent", szUserAgent);
diff --git a/plugins/SendScreenshotPlus/src/CSend.cpp b/plugins/SendScreenshotPlus/src/CSend.cpp
index 57ea415646..a06829a422 100644
--- a/plugins/SendScreenshotPlus/src/CSend.cpp
+++ b/plugins/SendScreenshotPlus/src/CSend.cpp
@@ -45,7 +45,8 @@ CSend::CSend(HWND /*Owner*/, MCONTACT hContact, bool bAsync, bool bSilent) :
m_hSend(nullptr),
m_hOnSend(nullptr),
m_ErrorMsg(nullptr),
- m_ErrorTitle(nullptr)
+ m_ErrorTitle(nullptr),
+ m_nlhr(REQUEST_POST)
{
SetContact(hContact);
}
@@ -422,7 +423,7 @@ const char* CSend::GetHTMLContent(char* str, const char* startTag, const char* e
return begin;
}
-int CSend::HTTPFormCreate(MHttpRequest* nlhr, int requestType, const char* url, HTTPFormData* frm, size_t frmNum)
+int CSend::HTTPFormCreate(MHttpRequest* nlhr, const char* url, HTTPFormData* frm, size_t frmNum)
{
char boundary[16];
strcpy(boundary, "--M461C/");
@@ -439,7 +440,7 @@ int CSend::HTTPFormCreate(MHttpRequest* nlhr, int requestType, const char* url,
boundary[9 + i * 2] = (chcode < 0x0a ? '0' : 'a' - 0x0a) + chcode;
}
}
- nlhr->requestType = requestType;
+
nlhr->flags = NLHRF_HTTP11;
if (!strncmp(url, "https://", 8))
nlhr->flags |= NLHRF_SSL;
diff --git a/plugins/SendScreenshotPlus/src/CSend.h b/plugins/SendScreenshotPlus/src/CSend.h
index 5d9e48247b..fc7985574a 100644
--- a/plugins/SendScreenshotPlus/src/CSend.h
+++ b/plugins/SendScreenshotPlus/src/CSend.h
@@ -65,7 +65,7 @@ public:
void SetContact(MCONTACT hContact);
const char* GetURL() { return m_URL; }
const char* GetURLthumbnail() {return m_URLthumb; }
- uint8_t GetEnableItem() {return m_EnableItem;};
+ uint8_t GetEnableItem() {return m_EnableItem;};
wchar_t* GetErrorMsg() {return m_ErrorMsg;};
bool m_bDeleteAfterSend;
@@ -81,23 +81,25 @@ protected:
wchar_t* m_pszSendTyp; // hold string for error mess
char* m_pszProto; // Contact Proto Module
MCONTACT m_hContact; // Contact handle
- uint8_t m_EnableItem; // hold flag for send type
- uint8_t m_ChatRoom; // is Contact chatroom
+ uint8_t m_EnableItem; // hold flag for send type
+ uint8_t m_ChatRoom; // is Contact chatroom
void Error(LPCTSTR pszFormat, ...);
void svcSendFileExit();
void svcSendMsgExit(const char* szMessage);
void Exit(unsigned int Result);
- uint32_t m_cbEventMsg; // sizeof EventMsg(T) buffer
+ uint32_t m_cbEventMsg; // sizeof EventMsg(T) buffer
CMStringA m_szEventMsg; // EventMsg char*
HANDLE m_hSend; // protocol send handle
HANDLE m_hOnSend; // HookEventObj on ME_PROTO_ACK
-
+
MSGBOX m_box;
wchar_t* m_ErrorMsg;
wchar_t* m_ErrorTitle;
-
+
+ MHttpRequest m_nlhr;
+
void Unhook(){if(m_hOnSend) {UnhookEvent(m_hOnSend);m_hOnSend = nullptr;}}
void DB_EventAdd(uint16_t EventType);
@@ -130,7 +132,7 @@ protected:
};
static const char* GetHTMLContent(char* str, const char* startTag, const char* endTag); // changes "str", can be successfully used only once
- int HTTPFormCreate(MHttpRequest* nlhr, int requestType, const char* url, HTTPFormData* frm, size_t frmNum); // returns "0" on success, Exit() will be called on failure (stop processing)
+ int HTTPFormCreate(MHttpRequest* nlhr, const char* url, HTTPFormData* frm, size_t frmNum); // returns "0" on success, Exit() will be called on failure (stop processing)
};
#endif
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
index 2826dd18c2..981c18f399 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.cpp
@@ -30,8 +30,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/////////////////////////////////////////////////////////////////////////////////////////
-CSendHost_ImageShack::CSendHost_ImageShack(HWND Owner, MCONTACT hContact, bool bAsync)
- : CSend(Owner, hContact, bAsync)
+CSendHost_ImageShack::CSendHost_ImageShack(HWND Owner, MCONTACT hContact, bool bAsync) :
+ CSend(Owner, hContact, bAsync)
{
m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
m_pszSendTyp = LPGENW("Image upload");
@@ -59,7 +59,7 @@ int CSendHost_ImageShack::Send()
{ "public", "no" },
{ "key", HTTPFORM_8BIT(DEVKEY_IMAGESHACK) },
};
- int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, "http://imageshack.us/upload_api.php", frm, sizeof(frm) / sizeof(HTTPFormData));
+ int error = HTTPFormCreate(&m_nlhr, "http://imageshack.us/upload_api.php", frm, sizeof(frm) / sizeof(HTTPFormData));
mir_free(tmp);
if (error)
return !m_bAsync;
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h
index 3b6212eb70..6ba8153342 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h
+++ b/plugins/SendScreenshotPlus/src/CSendHost_ImageShack.h
@@ -40,10 +40,8 @@ public:
int Send() override;
protected:
- MHttpRequest m_nlhr;
-
- void SendThread();
- static void SendThreadWrapper(void * Obj);
+ void SendThread();
+ static void SendThreadWrapper(void * Obj);
};
#endif
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
index da8010da07..b5bd858ab5 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.cpp
@@ -42,7 +42,7 @@ int CSendHost_Imgur::Send()
{ "image", HTTPFORM_FILE(tmp) },
};
- int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, "https://api.imgur.com/3/image", frm, _countof(frm));
+ int error = HTTPFormCreate(&m_nlhr, "https://api.imgur.com/3/image", frm, _countof(frm));
mir_free(tmp);
if (error)
return !m_bAsync;
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_imgur.h b/plugins/SendScreenshotPlus/src/CSendHost_imgur.h
index c99aaf8fef..4db1c425ec 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_imgur.h
+++ b/plugins/SendScreenshotPlus/src/CSendHost_imgur.h
@@ -24,7 +24,6 @@ class CSendHost_Imgur : public CSend {
int Send() override;
protected:
- MHttpRequest m_nlhr;
static void SendThread(void* obj);
};
#endif
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
index e9f975190b..a19d6ebc06 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
+++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.cpp
@@ -15,8 +15,9 @@
*/
#include "stdafx.h"
-CSendHost_UploadPie::CSendHost_UploadPie(HWND Owner, MCONTACT hContact, bool bAsync, int expire)
- : m_expire(expire), CSend(Owner, hContact, bAsync)
+CSendHost_UploadPie::CSendHost_UploadPie(HWND Owner, MCONTACT hContact, bool bAsync, int expire) :
+ CSend(Owner, hContact, bAsync),
+ m_expire(expire)
{
m_EnableItem = SS_DLG_DESCRIPTION | SS_DLG_AUTOSEND | SS_DLG_DELETEAFTERSSEND;
m_pszSendTyp = LPGENW("Image upload");
@@ -46,7 +47,7 @@ int CSendHost_UploadPie::Send()
{ "expire", HTTPFORM_INT(m_expire) },
};
- int error = HTTPFormCreate(&m_nlhr, REQUEST_POST, kHostURL, frm, _countof(frm));
+ int error = HTTPFormCreate(&m_nlhr, kHostURL, frm, _countof(frm));
mir_free(tmp);
if (error)
return !m_bAsync;
diff --git a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h
index 7a69e4733e..93f7f33b84 100644
--- a/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h
+++ b/plugins/SendScreenshotPlus/src/CSendHost_uploadpie.h
@@ -24,7 +24,6 @@ class CSendHost_UploadPie : public CSend {
protected:
int m_expire;
- MHttpRequest m_nlhr;
static void SendThread(void* obj);
};
#endif
diff --git a/plugins/SmileyAdd/src/download.cpp b/plugins/SmileyAdd/src/download.cpp
index 1aa2ac1fd4..0695876acc 100644
--- a/plugins/SmileyAdd/src/download.cpp
+++ b/plugins/SmileyAdd/src/download.cpp
@@ -44,8 +44,7 @@ bool InternetDownloadFile(const char *szUrl, char *szDest, HNETLIBCONN &hHttpDwn
int result = 0xBADBAD;
// initialize the netlib request
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_PERSISTENT | NLHRF_REDIRECT;
nlhr.m_szUrl = szUrl;
nlhr.nlc = hHttpDwnl;
diff --git a/protocols/CloudFile/src/http_request.h b/protocols/CloudFile/src/http_request.h
index 214ecea761..c9921cfd76 100644
--- a/protocols/CloudFile/src/http_request.h
+++ b/protocols/CloudFile/src/http_request.h
@@ -22,12 +22,9 @@ class HttpRequest : public MHttpRequest
private:
CMStringA m_szUrl;
- void Init(int type)
+ void Init()
{
- requestType = type;
flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP;
- nlc = NULL;
- timeout = 0;
}
protected:
@@ -78,16 +75,18 @@ protected:
}
public:
- HttpRequest(int type, LPCSTR url)
+ HttpRequest(int type, LPCSTR url) :
+ MHttpRequest(type)
{
- Init(type);
+ Init();
m_szUrl = url;
}
- HttpRequest(int type, CMStringDataFormat, LPCSTR urlFormat, ...)
+ HttpRequest(int type, CMStringDataFormat, LPCSTR urlFormat, ...) :
+ MHttpRequest(type)
{
- Init(type);
+ Init();
va_list formatArgs;
va_start(formatArgs, urlFormat);
diff --git a/protocols/CurrencyRates/src/HTTPSession.cpp b/protocols/CurrencyRates/src/HTTPSession.cpp
index a00a71d635..4bb0374ad1 100644
--- a/protocols/CurrencyRates/src/HTTPSession.cpp
+++ b/protocols/CurrencyRates/src/HTTPSession.cpp
@@ -20,8 +20,7 @@ bool CHTTPSession::ReadResponce(CMStringW &rsResponce)
if (m_szUrl.IsEmpty())
return false;
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
nlhr.m_szUrl = m_szUrl;
nlhr.AddHeader("User-Agent", NETLIB_USER_AGENT);
diff --git a/protocols/Facebook/src/avatars.cpp b/protocols/Facebook/src/avatars.cpp
index ba5ae845ec..b395da7805 100644
--- a/protocols/Facebook/src/avatars.cpp
+++ b/protocols/Facebook/src/avatars.cpp
@@ -33,9 +33,8 @@ void FacebookProto::GetAvatarFilename(MCONTACT hContact, wchar_t *pwszFileName)
void __cdecl FacebookProto::AvatarsUpdate(void *)
{
- MHttpRequest req;
+ MHttpRequest req(REQUEST_GET);
req.flags = NLHRF_NODUMP | NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT;
- req.requestType = REQUEST_GET;
CMStringA szParams((m_bUseBigAvatars) ? "type=large" : "type=normal");
szParams.AppendFormat("&access_token=%s", m_szAuthToken.c_str());
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index 69cb6b6940..63b292a77e 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -760,9 +760,8 @@ void FacebookProto::OnPublishPrivateMessage(const JSONNode &root)
// wszFileName.Format(L"%s\\STK{%S}.webp", wszPath.c_str(), stickerId.c_str());
std::string szUrl = sticker["thread_image"]["uri"].as_string();
- MHttpRequest req;
+ MHttpRequest req(REQUEST_GET);
req.flags = NLHRF_NODUMP | NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT;
- req.requestType = REQUEST_GET;
req.m_szUrl = szUrl.c_str();
MHttpResponse *pReply = Netlib_HttpTransaction(m_hNetlibUser, &req);
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp
index c9887a1da4..0bfce1c00c 100644
--- a/protocols/Gadu-Gadu/src/avatar.cpp
+++ b/protocols/Gadu-Gadu/src/avatar.cpp
@@ -51,8 +51,7 @@ bool GaduProto::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts)
char szUrl[128];
mir_snprintf(szUrl, "http://api.gadu-gadu.pl/avatars/%d/0.xml", uin);
- MHttpRequest req;
- req.requestType = REQUEST_GET;
+ MHttpRequest req(REQUEST_GET);
req.m_szUrl = szUrl;
req.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_REDIRECT;
@@ -225,8 +224,7 @@ void __cdecl GaduProto::avatarrequestthread(void*)
ai.hContact = data->hContact;
ai.format = getByte(ai.hContact, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE);
- MHttpRequest req;
- req.requestType = REQUEST_GET;
+ MHttpRequest req(REQUEST_GET);
req.m_szUrl = data->szAvatarURL;
req.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_REDIRECT;
@@ -372,8 +370,7 @@ void __cdecl GaduProto::setavatarthread(void *param)
char* token = getStringA(GG_KEY_TOKEN);
// construct request
- MHttpRequest req = {};
- req.requestType = REQUEST_POST;
+ MHttpRequest req(REQUEST_POST);
req.m_szUrl = "http://avatars.nowe.gg/upload";
req.flags = NLHRF_NODUMP | NLHRF_HTTP11;
req.AddHeader("X-Request", "JSON");
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp
index 084b4df1bf..70f145ce33 100644
--- a/protocols/Gadu-Gadu/src/oauth.cpp
+++ b/protocols/Gadu-Gadu/src/oauth.cpp
@@ -283,8 +283,7 @@ int GaduProto::oauth_receivetoken()
NLHR_PTR resp(0);
{
- MHttpRequest req;
- req.requestType = REQUEST_POST;
+ MHttpRequest req(REQUEST_POST);
req.m_szUrl = "http://api.gadu-gadu.pl/request_token";
req.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_PERSISTENT;
req.AddHeader("User-Agent", GG8_VERSION);
@@ -313,8 +312,7 @@ int GaduProto::oauth_receivetoken()
// 2. Obtaining User Authorization
debugLogA("oauth_receivetoken(): Obtaining User Authorization...");
{
- MHttpRequest req;
- req.requestType = REQUEST_POST;
+ MHttpRequest req(REQUEST_POST);
req.m_szUrl = "https://login.gadu-gadu.pl/authorize";
req.flags = NLHRF_NODUMP | NLHRF_HTTP11;
req.m_szParam.Format("callback_url=%s&request_token=%s&uin=%s&password=%s", ptrA(oauth_uri_escape("http://www.mojageneracja.pl")), token, uin, password);
@@ -335,8 +333,7 @@ int GaduProto::oauth_receivetoken()
token = nullptr;
token_secret = nullptr;
{
- MHttpRequest req;
- req.requestType = REQUEST_POST;
+ MHttpRequest req(REQUEST_POST);
req.m_szUrl = "http://api.gadu-gadu.pl/access_token";
req.flags = NLHRF_NODUMP | NLHRF_HTTP11 | NLHRF_PERSISTENT;
req.nlc = nlc;
diff --git a/protocols/GmailNotifier/src/check.cpp b/protocols/GmailNotifier/src/check.cpp
index df86f3fa0d..34a123390c 100644
--- a/protocols/GmailNotifier/src/check.cpp
+++ b/protocols/GmailNotifier/src/check.cpp
@@ -67,10 +67,9 @@ void CheckMailInbox(Account *curAcc)
szBody.Append("&password=");
szBody.Append(curAcc->pass);
- MHttpRequest nlhr;
+ MHttpRequest nlhr(REQUEST_POST);
nlhr.m_szUrl = szUrl.GetBuffer();
nlhr.m_szParam = szBody;
- nlhr.requestType = REQUEST_POST;
nlhr.AddHeader("Content-Type", "application/x-www-form-urlencoded");
NLHR_PTR nlu(Netlib_HttpTransaction(hNetlibUser, &nlhr));
@@ -93,9 +92,8 @@ void CheckMailInbox(Account *curAcc)
else
szUrl.Append("/mail/feed/atom");
- MHttpRequest nlhr;
- nlhr.m_szUrl = szUrl.GetBuffer();
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
+ nlhr.m_szUrl = szUrl;
nlhr.AddHeader("Authorization", szAuth.GetBuffer());
NLHR_PTR nlu(Netlib_HttpTransaction(hNetlibUser, &nlhr));
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp
index f58d6a3a46..616a629c59 100644
--- a/protocols/JabberG/src/jabber_file.cpp
+++ b/protocols/JabberG/src/jabber_file.cpp
@@ -49,8 +49,7 @@ void __cdecl CJabberProto::OfflineFileThread(OFDTHREAD *ofd)
}
// initialize the netlib request
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_HTTP11 | NLHRF_DUMPASTEXT | NLHRF_REDIRECT;
nlhr.m_szUrl = url;
@@ -127,8 +126,7 @@ void CJabberProto::OnReceiveOfflineFile(DB::FILE_BLOB &blob, void *pHandle)
void __cdecl CJabberProto::FileReceiveHttpThread(filetransfer *ft)
{
- MHttpRequest req;
- req.requestType = REQUEST_GET;
+ MHttpRequest req(REQUEST_GET);
req.m_szUrl = ft->httpPath;
NLHR_PTR pResp(Netlib_HttpTransaction(m_hNetlibUser, &req));
@@ -154,8 +152,7 @@ void CJabberProto::FileProcessHttpDownload(MCONTACT hContact, const char *jid, c
szName.AppendChar(*b++);
auto *pszName = szName.c_str();
- MHttpRequest req;
- req.requestType = REQUEST_HEAD;
+ MHttpRequest req(REQUEST_HEAD);
req.m_szUrl = pszUrl;
filetransfer *ft = new filetransfer(this, 0);
diff --git a/protocols/JabberG/src/jabber_ft.cpp b/protocols/JabberG/src/jabber_ft.cpp
index 752ab550a9..f4f088daa6 100644
--- a/protocols/JabberG/src/jabber_ft.cpp
+++ b/protocols/JabberG/src/jabber_ft.cpp
@@ -691,8 +691,7 @@ LBL_Fail:
if (!szUrl)
goto LBL_Fail;
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_PUT;
+ MHttpRequest nlhr(REQUEST_PUT);
nlhr.flags = NLHRF_NODUMPSEND | NLHRF_SSL | NLHRF_REDIRECT;
nlhr.m_szUrl = szUrl;
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 2f0ba8fa34..1f750bc08c 100644
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp
@@ -881,8 +881,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param)
OBJLIST<JABBER_HTTP_AVATARS> &avs = *(OBJLIST<JABBER_HTTP_AVATARS>*)param;
HNETLIBCONN hHttpCon = nullptr;
for (auto &it : avs) {
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_HTTP11 | NLHRF_REDIRECT | NLHRF_PERSISTENT;
nlhr.m_szUrl = it->Url;
nlhr.nlc = hHttpCon;
diff --git a/protocols/MinecraftDynmap/src/communication.cpp b/protocols/MinecraftDynmap/src/communication.cpp
index f7094c80f6..c09d069a83 100644
--- a/protocols/MinecraftDynmap/src/communication.cpp
+++ b/protocols/MinecraftDynmap/src/communication.cpp
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
MHttpResponse* MinecraftDynmapProto::sendRequest(const int request_type, std::string *post_data, std::string *get_data)
{
// Prepare the request
- MHttpRequest nlhr;
+ MHttpRequest nlhr(REQUEST_GET);
// FIXME: get server
@@ -40,7 +40,6 @@ MHttpResponse* MinecraftDynmapProto::sendRequest(const int request_type, std::st
nlhr.requestType = REQUEST_POST;
nlhr.SetData(post_data->c_str(), post_data->length());
}
- else nlhr.requestType = REQUEST_GET;
// Set headers - it depends on requestType so it must be after setting that
if (request_type == REQUEST_POST)
diff --git a/protocols/NewsAggregator/Src/Utils.cpp b/protocols/NewsAggregator/Src/Utils.cpp
index c5f1df5b95..60aec00266 100644
--- a/protocols/NewsAggregator/Src/Utils.cpp
+++ b/protocols/NewsAggregator/Src/Utils.cpp
@@ -47,10 +47,9 @@ void NetlibUnInit()
void GetNewsData(wchar_t *tszUrl, char **szData, MCONTACT hContact, CFeedEditor *pEditDlg)
{
Netlib_LogfW(hNetlibUser, L"Getting feed data %s.", tszUrl);
- MHttpRequest nlhr;
// initialize the netlib request
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
if (wcsstr(tszUrl, L"https://") != nullptr)
nlhr.flags |= NLHRF_SSL;
@@ -205,8 +204,7 @@ time_t DateToUnixTime(const char *stamp, bool FeedType)
bool DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal)
{
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
nlhr.m_szUrl = _T2A(tszURL);
nlhr.AddHeader("User-Agent", NETLIB_USER_AGENT);
diff --git a/protocols/Non-IM Contact/src/http.cpp b/protocols/Non-IM Contact/src/http.cpp
index 5aba5bbd8d..5e9d0a4821 100644
--- a/protocols/Non-IM Contact/src/http.cpp
+++ b/protocols/Non-IM Contact/src/http.cpp
@@ -35,8 +35,7 @@ HNETLIBUSER hNetlibUser;
int InternetDownloadFile(char *szUrl)
{
// initialize the netlib request
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_DUMPASTEXT;
nlhr.m_szUrl = szUrl;
diff --git a/protocols/Tox/src/http_request.h b/protocols/Tox/src/http_request.h
index 1e140b2ef0..cacc66f51d 100644
--- a/protocols/Tox/src/http_request.h
+++ b/protocols/Tox/src/http_request.h
@@ -19,28 +19,27 @@ public:
class HttpRequest : public MHttpRequest
{
- void Init(int type)
+ void Init()
{
- requestType = type;
flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMPSEND | NLHRF_DUMPASTEXT;
- nlc = nullptr;
- timeout = 0;
}
protected:
enum HttpRequestUrlFormat { FORMAT };
public:
- HttpRequest(int type, LPCSTR url)
+ HttpRequest(int type, LPCSTR url) :
+ MHttpRequest(type)
{
- Init(type);
+ Init();
m_szUrl = url;
}
- HttpRequest(int type, HttpRequestUrlFormat, LPCSTR urlFormat, ...)
+ HttpRequest(int type, HttpRequestUrlFormat, LPCSTR urlFormat, ...) :
+ MHttpRequest(type)
{
- Init(type);
+ Init();
va_list formatArgs;
va_start(formatArgs, urlFormat);
diff --git a/protocols/Twitter/src/utility.cpp b/protocols/Twitter/src/utility.cpp
index 7e853b8a32..c46c146390 100644
--- a/protocols/Twitter/src/utility.cpp
+++ b/protocols/Twitter/src/utility.cpp
@@ -71,8 +71,7 @@ void CTwitterProto::ShowPopup(const char *text, int Error)
bool save_url(HNETLIBUSER hNetlib, const CMStringA &url, const CMStringW &filename)
{
- MHttpRequest req;
- req.requestType = REQUEST_GET;
+ MHttpRequest req(REQUEST_GET);
req.flags = NLHRF_HTTP11 | NLHRF_REDIRECT;
req.m_szUrl = const_cast<char*>(url.c_str());
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index c3abf2d9ec..3f15bcac16 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -1469,9 +1469,8 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
if (GetFileAttributesW(wszFileName) == INVALID_FILE_ATTRIBUTES) {
T2Utf szUrl(wszUrl);
- MHttpRequest req;
+ MHttpRequest req(REQUEST_GET);
req.flags = NLHRF_NODUMP | NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT;
- req.requestType = REQUEST_GET;
req.m_szUrl = szUrl.get();
MHttpResponse *pReply = Netlib_HttpTransaction(m_hNetlibUser, &req);
diff --git a/protocols/VKontakte/src/vk_captcha.cpp b/protocols/VKontakte/src/vk_captcha.cpp
index 5ff52d732f..3969850fe8 100644
--- a/protocols/VKontakte/src/vk_captcha.cpp
+++ b/protocols/VKontakte/src/vk_captcha.cpp
@@ -33,8 +33,7 @@ bool CVkProto::RunCaptchaForm(LPCSTR szUrl, CMStringA &result)
Utils_OpenUrl(szCaptchaAssistant);
}
else {
- MHttpRequest req;
- req.requestType = REQUEST_GET;
+ MHttpRequest req(REQUEST_GET);
req.m_szUrl = (LPSTR)szUrl;
req.flags = VK_NODUMPHEADERS;
diff --git a/protocols/VKontakte/src/vk_pollserver.cpp b/protocols/VKontakte/src/vk_pollserver.cpp
index 8d6b9abae9..10bd5c7e43 100644
--- a/protocols/VKontakte/src/vk_pollserver.cpp
+++ b/protocols/VKontakte/src/vk_pollserver.cpp
@@ -253,8 +253,7 @@ int CVkProto::PollServer()
CMStringA szReqUrl(FORMAT, "https://%s?act=a_check&key=%s&ts=%s&wait=25&access_token=%s&mode=%d&version=%d", m_szPollingServer, m_szPollingKey, m_szPollingTs, m_szAccessToken, 106, 2);
// see mode parametr description on https://vk.com/dev/using_longpoll (Russian version)
- MHttpRequest req;
- req.requestType = REQUEST_GET;
+ MHttpRequest req(REQUEST_GET);
req.m_szUrl = szReqUrl.GetBuffer();
req.flags = VK_NODUMPHEADERS | NLHRF_PERSISTENT | NLHRF_HTTP11 | NLHRF_SSL;
req.timeout = 30000;
diff --git a/protocols/Weather/src/weather_http.cpp b/protocols/Weather/src/weather_http.cpp
index 99c262ec6a..79c9efd21e 100644
--- a/protocols/Weather/src/weather_http.cpp
+++ b/protocols/Weather/src/weather_http.cpp
@@ -40,8 +40,7 @@ int InternetDownloadFile(char *szUrl, char *cookie, char *userAgent, wchar_t **s
userAgent = NETLIB_USER_AGENT;
// initialize the netlib request
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11 | NLHRF_REDIRECT;
nlhr.m_szUrl = szUrl;
nlhr.AddHeader("User-Agent", userAgent);
diff --git a/protocols/WebView/src/webview_getdata.cpp b/protocols/WebView/src/webview_getdata.cpp
index babfe3cca8..ba913bab5f 100644
--- a/protocols/WebView/src/webview_getdata.cpp
+++ b/protocols/WebView/src/webview_getdata.cpp
@@ -104,8 +104,7 @@ void GetData(void *param)
if (mir_strlen(url) < 3)
WErrorPopup(hContact, TranslateT("URL not supplied"));
- MHttpRequest nlhr;
- nlhr.requestType = REQUEST_GET;
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_DUMPASTEXT;
nlhr.m_szUrl = url;
nlhr.AddHeader("User-Agent", NETLIB_USER_AGENT);
diff --git a/protocols/WhatsApp/src/avatars.cpp b/protocols/WhatsApp/src/avatars.cpp
index bfd3e16d72..32e57706a4 100644
--- a/protocols/WhatsApp/src/avatars.cpp
+++ b/protocols/WhatsApp/src/avatars.cpp
@@ -130,9 +130,8 @@ void WhatsAppProto::ServerFetchAvatar(const char *jid)
bool CMPlugin::SaveFile(const char *pszUrl, PROTO_AVATAR_INFORMATION &ai)
{
- MHttpRequest req;
+ MHttpRequest req(REQUEST_GET);
req.flags = NLHRF_NODUMP | NLHRF_PERSISTENT | NLHRF_SSL | NLHRF_HTTP11 | NLHRF_REDIRECT;
- req.requestType = REQUEST_GET;
req.m_szUrl = pszUrl;
req.nlc = hAvatarConn;
diff --git a/protocols/WhatsApp/src/utils.cpp b/protocols/WhatsApp/src/utils.cpp
index 0333c62ca5..ff1a5b5daf 100644
--- a/protocols/WhatsApp/src/utils.cpp
+++ b/protocols/WhatsApp/src/utils.cpp
@@ -519,8 +519,7 @@ WAMediaKeys::WAMediaKeys(const uint8_t *pKey, size_t keyLen, const char *pszMedi
MBinBuffer WhatsAppProto::DownloadEncryptedFile(const char *url, const ProtobufCBinaryData &mediaKeys, const char *pszMediaType)
{
- MHttpRequest req;
- req.requestType = REQUEST_GET;
+ MHttpRequest req(REQUEST_GET);
req.m_szUrl = url;
req.AddHeader("Origin", "https://web.whatsapp.com");
diff --git a/src/mir_app/src/MHttpRequest.cpp b/src/mir_app/src/MHttpRequest.cpp
index e5dca2f850..d2ba1f0879 100644
--- a/src/mir_app/src/MHttpRequest.cpp
+++ b/src/mir_app/src/MHttpRequest.cpp
@@ -23,7 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
-MHttpRequest::MHttpRequest()
+MHttpRequest::MHttpRequest(int _1) :
+ requestType(_1),
+ flags(0),
+ pUserInfo(nullptr),
+ nlc(0),
+ timeout(30000)
{
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index f7ca388bde..81b4f9d53a 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -582,7 +582,7 @@ g_hevSettingChanged @696 NONAME
?MetaRemoveSubHistory@MDatabaseReadonly@@UAGHPAUDBCachedContact@@@Z @704 NONAME
Chat_GetGroup @705
Chat_SetGroup @706
-??0MHttpRequest@@QAE@XZ @708 NONAME
+??0MHttpRequest@@QAE@H@Z @708 NONAME
??1MHttpRequest@@QAE@XZ @709 NONAME
??6@YGPAUMHttpRequest@@PAU0@ABUCHAR_PARAM@@@Z @711 NONAME
??6@YGPAUMHttpRequest@@PAU0@ABUINT_PARAM@@@Z @712 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 6714b366cb..86f013224d 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -582,7 +582,7 @@ g_hevSettingChanged @696 NONAME
?MetaRemoveSubHistory@MDatabaseReadonly@@UEAAHPEAUDBCachedContact@@@Z @704 NONAME
Chat_GetGroup @705
Chat_SetGroup @706
-??0MHttpRequest@@QEAA@XZ @708 NONAME
+??0MHttpRequest@@QEAA@H@Z @708 NONAME
??1MHttpRequest@@QEAA@XZ @709 NONAME
??6@YAPEAUMHttpRequest@@PEAU0@AEBUCHAR_PARAM@@@Z @711 NONAME
??6@YAPEAUMHttpRequest@@PEAU0@AEBUINT_PARAM@@@Z @712 NONAME
diff --git a/src/mir_app/src/netlib_autoproxy.cpp b/src/mir_app/src/netlib_autoproxy.cpp
index afee108825..f030b76f2f 100644
--- a/src/mir_app/src/netlib_autoproxy.cpp
+++ b/src/mir_app/src/netlib_autoproxy.cpp
@@ -52,7 +52,7 @@ static void GetFile(char *szUrl, AUTO_PROXY_SCRIPT_BUFFER &buf)
nlu.toLog = 1;
// initialize the netlib request
- MHttpRequest nlhr;
+ MHttpRequest nlhr(0);
nlhr.flags = NLHRF_HTTP11 | NLHRF_DUMPASTEXT | NLHRF_REDIRECT;
nlhr.m_szUrl = szUrl;
diff --git a/src/mir_app/src/netlib_openconn.cpp b/src/mir_app/src/netlib_openconn.cpp
index 5d2bf20c24..58443d090e 100644
--- a/src/mir_app/src/netlib_openconn.cpp
+++ b/src/mir_app/src/netlib_openconn.cpp
@@ -309,8 +309,7 @@ static bool NetlibInitHttpsConnection(NetlibConnection *nlc)
}
MMemoryChunkStorage storage;
- MHttpRequest nlhrSend;
- nlhrSend.requestType = REQUEST_CONNECT;
+ MHttpRequest nlhrSend(REQUEST_CONNECT);
nlhrSend.flags = NLHRF_DUMPPROXY | NLHRF_HTTP11 | NLHRF_NOPROXY | NLHRF_REDIRECT;
nlhrSend.m_szUrl = szUrl;
diff --git a/src/mir_app/src/netlib_websocket.cpp b/src/mir_app/src/netlib_websocket.cpp
index da2fee6c28..1bd8f2e4cd 100644
--- a/src/mir_app/src/netlib_websocket.cpp
+++ b/src/mir_app/src/netlib_websocket.cpp
@@ -35,7 +35,7 @@ MIR_APP_DLL(MHttpResponse*) WebSocket_Connect(HNETLIBUSER nlu, const char *szHos
if (!mir_strncmp(tmpHost, "wss://", 6))
tmpHost.Delete(0, 6);
- auto *nlr = new MHttpRequest;
+ auto *nlr = new MHttpRequest(0);
nlr->flags = NLHRF_PERSISTENT | NLHRF_HTTP11 | NLHRF_SSL;
nlr->m_szUrl = tmpHost.GetBuffer();
nlr->AddHeader("Accept", "*/*");