From 0156ed41dceeef48f070adf67f14d4ba4c4f6d61 Mon Sep 17 00:00:00 2001 From: aunsane Date: Thu, 28 Dec 2017 21:21:10 +0300 Subject: Steam: refactoring - reworking http requests - added ability to get game name by appid - another attempt to fix #633 - minor refactoring --- protocols/Steam/src/api/app_info.h | 16 ++++++++++ protocols/Steam/src/api/authorization.h | 34 ++++++++++----------- protocols/Steam/src/api/avatar.h | 2 +- protocols/Steam/src/api/captcha.h | 4 ++- protocols/Steam/src/api/enums.h | 32 ++++++++++++++++++++ protocols/Steam/src/api/friend.h | 7 +++-- protocols/Steam/src/api/friend_list.h | 52 +++++++++++++-------------------- protocols/Steam/src/api/history.h | 17 ++++++----- protocols/Steam/src/api/login.h | 17 +++++------ protocols/Steam/src/api/message.h | 32 +++++++++----------- protocols/Steam/src/api/pending.h | 48 ++++++++++++++++++------------ protocols/Steam/src/api/poll.h | 20 +++++-------- protocols/Steam/src/api/rsa_key.h | 9 +++--- protocols/Steam/src/api/search.h | 14 +++++---- protocols/Steam/src/api/session.h | 12 ++++---- 15 files changed, 182 insertions(+), 134 deletions(-) create mode 100644 protocols/Steam/src/api/app_info.h create mode 100644 protocols/Steam/src/api/enums.h (limited to 'protocols/Steam/src/api') diff --git a/protocols/Steam/src/api/app_info.h b/protocols/Steam/src/api/app_info.h new file mode 100644 index 0000000000..b08a3f38d6 --- /dev/null +++ b/protocols/Steam/src/api/app_info.h @@ -0,0 +1,16 @@ +#ifndef _STEAM_REQUEST_APP_INFO_H_ +#define _STEAM_REQUEST_APP_INFO_H_ + +class GetAppInfoRequest : public HttpRequest +{ +public: + GetAppInfoRequest(const char *token, const char *appIds) : + HttpRequest(HttpGet, STEAM_API_URL "/ISteamGameOAuth/GetAppInfo/v0001") + { + Uri + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("appIds", appIds); + } +}; + +#endif //_STEAM_REQUEST_APP_INFO_H_ diff --git a/protocols/Steam/src/api/authorization.h b/protocols/Steam/src/api/authorization.h index cba8d4d274..3d02c5deb5 100644 --- a/protocols/Steam/src/api/authorization.h +++ b/protocols/Steam/src/api/authorization.h @@ -5,27 +5,27 @@ class AuthorizationRequest : public HttpRequest { public: AuthorizationRequest(const char *username, const char *password, const char *timestamp, const char *twoFactorCode, const char *guardCode, const char *guardId = "", const char *captchaId = "-1", const char *captchaText = "") : - HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobilelogin/dologin/") + HttpRequest(HttpPost, STEAM_WEB_URL "/mobilelogin/dologin/") { flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP; - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); - AddHeader("Referer", STEAM_WEB_URL "/mobilelogin/dologin?oauth_client_id=3638BFB1&oauth_scope=read_profile%20write_profile%20read_client%20write_client"); - AddHeader("Cookie", "mobileClientVersion=1291812;forceMobile=1;mobileClient=ios"); + Headers + << CHAR_PARAM("Referer", STEAM_WEB_URL "/mobilelogin/dologin?oauth_client_id=3638BFB1&oauth_scope=read_profile%20write_profile%20read_client%20write_client") + << CHAR_PARAM("Cookie", "mobileClientVersion=1291812;forceMobile=1;mobileClient=ios"); - CMStringA data; - data.AppendFormat("password=%s&username=%s&twofactorcode=%s&emailauth=%s&loginfriendlyname=%s&oauth_client_id=3638BFB1&captchagid=%s&captcha_text=%s&emailsteamid=%s&rsatimestamp=%s&rememberlogin=false&donotcache=%lld", - ptrA(mir_urlEncode(password)), - ptrA(mir_urlEncode(username)), - twoFactorCode, - guardCode, - "Miranda%20NG", - captchaId, - ptrA(mir_urlEncode(captchaText)), - guardId, - timestamp, - time(NULL)); - SetData(data, data.GetLength()); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("oauth_client_id", "3638BFB1") + << CHAR_PARAM("loginfriendlyname", "Miranda NG") + << CHAR_PARAM("password", password) + << CHAR_PARAM("username", username) + << CHAR_PARAM("twofactorcode", twoFactorCode) + << CHAR_PARAM("emailsteamid", guardId) + << CHAR_PARAM("emailauth", guardCode) + << CHAR_PARAM("captchagid", captchaId) + << CHAR_PARAM("captcha_text", captchaText) + << CHAR_PARAM("rsatimestamp", timestamp) + << BOOL_PARAM("rememberlogin", false) + << INT64_PARAM("donotcache", time(NULL)); } }; diff --git a/protocols/Steam/src/api/avatar.h b/protocols/Steam/src/api/avatar.h index 28e573d9d1..521536550e 100644 --- a/protocols/Steam/src/api/avatar.h +++ b/protocols/Steam/src/api/avatar.h @@ -5,7 +5,7 @@ class GetAvatarRequest : public HttpRequest { public: GetAvatarRequest(const char *url) : - HttpRequest(REQUEST_GET, url) + HttpRequest(HttpGet, url) { flags = NLHRF_HTTP11 | NLHRF_NODUMP; } diff --git a/protocols/Steam/src/api/captcha.h b/protocols/Steam/src/api/captcha.h index 9619a09b54..0b8ba9191a 100644 --- a/protocols/Steam/src/api/captcha.h +++ b/protocols/Steam/src/api/captcha.h @@ -5,9 +5,11 @@ class GetCaptchaRequest : public HttpRequest { public: GetCaptchaRequest(const char *captchaId) : - HttpRequest(REQUEST_GET, FORMAT, STEAM_WEB_URL "/public/captcha.php?gid=%s", captchaId) + HttpRequest(HttpGet, STEAM_WEB_URL "/public/captcha.php") { flags = NLHRF_HTTP11 | NLHRF_NODUMP; + + Uri << CHAR_PARAM("gid", captchaId); } }; diff --git a/protocols/Steam/src/api/enums.h b/protocols/Steam/src/api/enums.h new file mode 100644 index 0000000000..a24ce48b34 --- /dev/null +++ b/protocols/Steam/src/api/enums.h @@ -0,0 +1,32 @@ +#ifndef _STEAM_ENUMS_H_ +#define _STEAM_ENUMS_H_ + +enum PersonaState +{ + Offline = 0, + Online = 1, + Busy = 2, + Away = 3, + Snooze = 4, + LookingToTrade = 5, + LookingToPlay = 6, + Max = 7, +}; + +enum StatusFlags +{ + Status = 1, + PlayerName = 2, + QueryPort = 4, + SourceID = 8, + Presence = 16, + Metadata = 32, + LastSeen = 64, + ClanInfo = 128, + GameExtraInfo = 256, + GameDataBlob = 512, + ClanTag = 1024, + Facebook = 2048, +} + +#endif //_STEAM_ENUMS_H_ diff --git a/protocols/Steam/src/api/friend.h b/protocols/Steam/src/api/friend.h index ade553f2c0..191e0b93fa 100644 --- a/protocols/Steam/src/api/friend.h +++ b/protocols/Steam/src/api/friend.h @@ -5,10 +5,11 @@ class GetUserSummariesRequest : public HttpRequest { public: GetUserSummariesRequest(const char *token, const char *steamIds) : - HttpRequest(REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/GetUserSummaries/v0001") + HttpRequest(HttpGet, STEAM_API_URL "/ISteamUserOAuth/GetUserSummaries/v0001") { - AddParameter("access_token", token); - AddParameter("steamids", steamIds); + Uri + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("steamids", steamIds); } }; diff --git a/protocols/Steam/src/api/friend_list.h b/protocols/Steam/src/api/friend_list.h index b6ab98402b..604e797a2d 100644 --- a/protocols/Steam/src/api/friend_list.h +++ b/protocols/Steam/src/api/friend_list.h @@ -5,11 +5,12 @@ class GetFriendListRequest : public HttpRequest { public: GetFriendListRequest(const char *token, const char *steamId, const char *relationship = "friend,ignoredfriend,requestrecipient") : - HttpRequest(REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/GetFriendList/v0001") + HttpRequest(HttpGet, STEAM_API_URL "/ISteamUserOAuth/GetFriendList/v0001") { - AddParameter("access_token", token); - AddParameter("steamid", steamId); - AddParameter("relationship", relationship); + Uri + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("steamid", steamId) + << CHAR_PARAM("relationship", relationship); } }; @@ -17,7 +18,7 @@ class AddFriendRequest : public HttpRequest { public: AddFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : - HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/AddFriendAjax") + HttpRequest(HttpPost, STEAM_WEB_URL "/actions/AddFriendAjax") { char login[MAX_PATH]; mir_snprintf(login, "%s||oauth:%s", steamId, token); @@ -25,15 +26,11 @@ public: char cookie[MAX_PATH]; mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); - char data[128]; - mir_snprintf(data, _countof(data), - "sessionID=%s&steamid=%s", - sessionId, - who); + Headers << CHAR_PARAM("Cookie", cookie); - SetData(data, strlen(data)); - AddHeader("Cookie", cookie); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("sessionID", sessionId) + << CHAR_PARAM("steamid", who); } }; @@ -41,7 +38,7 @@ class BlockFriendRequest : public HttpRequest { public: BlockFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : - HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/BlockUserAjax") + HttpRequest(HttpPost, STEAM_WEB_URL "/actions/BlockUserAjax") { char login[MAX_PATH]; mir_snprintf(login, "%s||oauth:%s", steamId, token); @@ -49,15 +46,12 @@ public: char cookie[MAX_PATH]; mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); - char data[128]; - mir_snprintf(data, _countof(data), - "sessionID=%s&action=ignore&steamid=%s", - sessionId, - who); + Headers << CHAR_PARAM("Cookie", cookie); - SetData(data, strlen(data)); - AddHeader("Cookie", cookie); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("sessionID", sessionId) + << CHAR_PARAM("steamid", who) + << CHAR_PARAM("action", "ignore"); } }; @@ -65,7 +59,7 @@ class RemoveFriendRequest : public HttpRequest { public: RemoveFriendRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : - HttpRequest(REQUEST_POST, STEAM_WEB_URL "/actions/RemoveFriendAjax") + HttpRequest(HttpPost, STEAM_WEB_URL "/actions/RemoveFriendAjax") { char login[MAX_PATH]; mir_snprintf(login, "%s||oauth:%s", steamId, token); @@ -73,15 +67,11 @@ public: char cookie[MAX_PATH]; mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); - char data[128]; - mir_snprintf(data, _countof(data), - "sessionID=%s&steamid=%s", - sessionId, - who); + Headers << CHAR_PARAM("Cookie", cookie); - SetData(data, strlen(data)); - AddHeader("Cookie", cookie); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("sessionID", sessionId) + << CHAR_PARAM("steamid", who); } }; diff --git a/protocols/Steam/src/api/history.h b/protocols/Steam/src/api/history.h index 09eed8a49c..f825622953 100644 --- a/protocols/Steam/src/api/history.h +++ b/protocols/Steam/src/api/history.h @@ -5,9 +5,9 @@ class GetConversationsRequest : public HttpRequest { public: GetConversationsRequest(const char *token) : - HttpRequest(REQUEST_GET, STEAM_API_URL "/IFriendMessagesService/GetActiveMessageSessions/v0001") + HttpRequest(HttpGet, STEAM_API_URL "/IFriendMessagesService/GetActiveMessageSessions/v0001") { - AddParameter("access_token", token); + Uri << CHAR_PARAM("access_token", token); } }; @@ -15,13 +15,14 @@ class GetHistoryMessagesRequest : public HttpRequest { public: GetHistoryMessagesRequest(const char *token, const char *steamId, const char *who, time_t since) : - HttpRequest(REQUEST_GET, STEAM_API_URL "/IFriendMessagesService/GetRecentMessages/v0001") + HttpRequest(HttpGet, STEAM_API_URL "/IFriendMessagesService/GetRecentMessages/v0001") { - AddParameter("access_token", token); - AddParameter("steamid1", steamId); - AddParameter("steamid2", who); - // Steam somehow doesn't respect too precise start time parameter, so we better request older time and then do own filtering again - AddParameter("rtime32_start_time=%d", since - 1500); + Uri + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("steamid1", steamId) + << CHAR_PARAM("steamid2", who) + // Steam somehow doesn't respect too precise start time parameter, so we better request older time and then do own filtering again + << INT64_PARAM("rtime32_start_time", since - 1500); } }; diff --git a/protocols/Steam/src/api/login.h b/protocols/Steam/src/api/login.h index 35ea1d8c74..3479ae75ff 100644 --- a/protocols/Steam/src/api/login.h +++ b/protocols/Steam/src/api/login.h @@ -5,13 +5,14 @@ class LogonRequest : public HttpRequest { public: LogonRequest(const char *token) : - HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logon/v0001") + HttpRequest(HttpPost, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logon/v0001") { char data[256]; mir_snprintf(data, "access_token=%s&ui_mode=web", token); - SetData(data, strlen(data)); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("ui_mode", "web"); } }; @@ -19,13 +20,11 @@ class LogoffRequest : public HttpRequest { public: LogoffRequest(const char *token, const char *umqId) : - HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logoff/v0001") + HttpRequest(HttpPost, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Logoff/v0001") { - char data[256]; - mir_snprintf(data, "access_token=%s&umqid=%s", token, umqId); - - SetData(data, strlen(data)); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("umqid", umqId); } }; diff --git a/protocols/Steam/src/api/message.h b/protocols/Steam/src/api/message.h index 77adb4a240..eee4c43b28 100644 --- a/protocols/Steam/src/api/message.h +++ b/protocols/Steam/src/api/message.h @@ -5,17 +5,14 @@ class SendMessageRequest : public HttpRequest { public: SendMessageRequest(const char *token, const char *umqId, const char *steamId, const char *text) : - HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001") + HttpRequest(HttpPost, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001") { - CMStringA data; - data.AppendFormat("access_token=%s&umqid=%s&steamid_dst=%s&type=saytext&text=%s", - token, - umqId, - steamId, - ptrA(mir_urlEncode(text))); - - SetData(data, data.GetLength()); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("umqid", umqId) + << CHAR_PARAM("steamid_dst", steamId) + << CHAR_PARAM("type", "saytext") + << CHAR_PARAM("text", text); } }; @@ -23,16 +20,13 @@ class SendTypingRequest : public HttpRequest { public: SendTypingRequest(const char *token, const char *umqId, const char *steamId) : - HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001") + HttpRequest(HttpPost, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Message/v0001") { - CMStringA data; - data.AppendFormat("access_token=%s&umqid=%s&steamid_dst=%s&type=typing", - token, - umqId, - steamId); - - SetData(data, data.GetLength()); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("umqid", umqId) + << CHAR_PARAM("steamid_dst", steamId) + << CHAR_PARAM("type", "typing"); } }; diff --git a/protocols/Steam/src/api/pending.h b/protocols/Steam/src/api/pending.h index 7c1964b6c5..a808fd172c 100644 --- a/protocols/Steam/src/api/pending.h +++ b/protocols/Steam/src/api/pending.h @@ -5,7 +5,7 @@ class ApprovePendingRequest : public HttpRequest { public: ApprovePendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : - HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) + HttpRequest(HttpPost, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) { char login[MAX_PATH]; mir_snprintf(login, "%s||oauth:%s", steamId, token); @@ -13,12 +13,16 @@ public: char cookie[MAX_PATH]; mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); - char data[MAX_PATH]; - mir_snprintf(data, "sessionID=%s&id=%s&perform=accept&action=approvePending&itype=friend&json=1&xml=0", sessionId, who); + Headers << CHAR_PARAM("Cookie", cookie); - SetData(data, strlen(data)); - AddHeader("Cookie", cookie); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("sessionID", sessionId) + << CHAR_PARAM("id", who) + << CHAR_PARAM("perform", "accept") + << CHAR_PARAM("action", "approvePending") + << CHAR_PARAM("itype", "friend") + << INT_PARAM("json", 1) + << INT_PARAM("xml", 0); } }; @@ -26,7 +30,7 @@ class IgnorePendingRequest : public HttpRequest { public: IgnorePendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : - HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) + HttpRequest(HttpPost, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) { char login[MAX_PATH]; mir_snprintf(login, "%s||oauth:%s", steamId, token); @@ -34,12 +38,16 @@ public: char cookie[MAX_PATH]; mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); - char data[MAX_PATH]; - mir_snprintf(data, "sessionID=%s&id=%s&perform=ignore&action=approvePending&itype=friend&json=1&xml=0", sessionId, who); + Headers << CHAR_PARAM("Cookie", cookie); - SetData(data, strlen(data)); - AddHeader("Cookie", cookie); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("sessionID", sessionId) + << CHAR_PARAM("id", who) + << CHAR_PARAM("perform", "ignore") + << CHAR_PARAM("action", "approvePending") + << CHAR_PARAM("itype", "friend") + << INT_PARAM("json", 1) + << INT_PARAM("xml", 0); } }; @@ -47,7 +55,7 @@ class BlockPendingRequest : public HttpRequest { public: BlockPendingRequest(const char *token, const char *sessionId, const char *steamId, const char *who) : - HttpRequest(REQUEST_POST, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) + HttpRequest(HttpPost, FORMAT, STEAM_WEB_URL "/profiles/%s/home_process", steamId) { char login[MAX_PATH]; mir_snprintf(login, "%s||oauth:%s", steamId, token); @@ -55,12 +63,16 @@ public: char cookie[MAX_PATH]; mir_snprintf(cookie, "steamLogin=%s;sessionid=%s;mobileClientVersion=1291812;forceMobile=1;mobileClient=ios", login, sessionId); - char data[MAX_PATH]; - mir_snprintf(data, "sessionID=%s&id=%s&perform=block&action=approvePending&itype=friend&json=1&xml=0", sessionId, who); + Headers << CHAR_PARAM("Cookie", cookie); - SetData(data, strlen(data)); - AddHeader("Cookie", cookie); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("sessionID", sessionId) + << CHAR_PARAM("id", who) + << CHAR_PARAM("perform", "block") + << CHAR_PARAM("action", "approvePending") + << CHAR_PARAM("itype", "friend") + << INT_PARAM("json", 1) + << INT_PARAM("xml", 0); } }; diff --git a/protocols/Steam/src/api/poll.h b/protocols/Steam/src/api/poll.h index 5c5da5674c..278dfb0439 100644 --- a/protocols/Steam/src/api/poll.h +++ b/protocols/Steam/src/api/poll.h @@ -5,23 +5,19 @@ class PollRequest : public HttpRequest { public: PollRequest(const char *token, const char *umqId, UINT32 messageId, int idleSeconds) : - HttpRequest(REQUEST_POST, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v0001") + HttpRequest(HttpPost, STEAM_API_URL "/ISteamWebUserPresenceOAuth/Poll/v0001") { timeout = (STEAM_API_TIMEOUT + 5) * 1000; // flags |= NLHRF_PERSISTENT; - CMStringA data; - data.AppendFormat("access_token=%s&umqid=%s&message=%u&secidletime=%d§imeout=%d", - token, - umqId, - messageId, - idleSeconds, - STEAM_API_TIMEOUT); + Headers << CHAR_PARAM("Connection", "keep-alive"); - SetData(data, data.GetLength()); - - AddHeader("Connection", "keep-alive"); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("umqid", umqId) + << INT64_PARAM("message", messageId) + << INT_PARAM("secidletime", idleSeconds) + << INT_PARAM("sectimeout", STEAM_API_TIMEOUT); } }; diff --git a/protocols/Steam/src/api/rsa_key.h b/protocols/Steam/src/api/rsa_key.h index 9f89a70403..27a002b717 100644 --- a/protocols/Steam/src/api/rsa_key.h +++ b/protocols/Steam/src/api/rsa_key.h @@ -5,15 +5,16 @@ class GetRsaKeyRequest : public HttpRequest { public: GetRsaKeyRequest(const char *username) : - HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobilelogin/getrsakey/") + HttpRequest(HttpPost, STEAM_WEB_URL "/mobilelogin/getrsakey/") { flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP; - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); - CMStringA data; data.AppendFormat("username=%s&donotcache=%lld", ptrA(mir_urlEncode(username)), time(NULL)); - SetData(data, data.GetLength()); + + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("username", username) + << INT64_PARAM("donotcache", time(NULL)); } }; diff --git a/protocols/Steam/src/api/search.h b/protocols/Steam/src/api/search.h index a22ed64431..a34c2e8398 100644 --- a/protocols/Steam/src/api/search.h +++ b/protocols/Steam/src/api/search.h @@ -5,13 +5,15 @@ class SearchRequest : public HttpRequest { public: SearchRequest(const char *token, const char *text, int offset = 0, int count = 30) : - HttpRequest(REQUEST_GET, STEAM_API_URL "/ISteamUserOAuth/Search/v0001") + HttpRequest(HttpGet, STEAM_API_URL "/ISteamUserOAuth/Search/v0001") { - AddParameter("access_token", token); - AddParameter("keywords", ptrA(mir_urlEncode(text))); - AddParameter("offset=%d", offset); - AddParameter("count=%d", count); - AddParameter("targets=users&fields=all"); + Uri + << CHAR_PARAM("access_token", token) + << CHAR_PARAM("keywords", text) + << INT_PARAM("offset=%d", offset) + << INT_PARAM("count=%d", count) + << CHAR_PARAM("targets", "users") + << CHAR_PARAM("fields", "all"); } }; diff --git a/protocols/Steam/src/api/session.h b/protocols/Steam/src/api/session.h index b00e470da6..d4e91721cb 100644 --- a/protocols/Steam/src/api/session.h +++ b/protocols/Steam/src/api/session.h @@ -5,19 +5,21 @@ class GetSessionRequest : public HttpRequest { public: GetSessionRequest(const char *token, const char *steamId, const char *cookie) : - HttpRequest(REQUEST_POST, STEAM_WEB_URL "/mobileloginsucceeded") + HttpRequest(HttpPost, STEAM_WEB_URL "/mobileloginsucceeded") { flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP; + Content = new FormUrlEncodedContent(this) + << CHAR_PARAM("oauth_token", token) + << CHAR_PARAM("steamid", steamId) + << CHAR_PARAM("webcookie", cookie); + char data[512]; mir_snprintf(data, _countof(data), "oauth_token=%s&steamid=%s&webcookie=%s", token, steamId, cookie); - - SetData(data, strlen(data)); - AddHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); } }; @@ -25,7 +27,7 @@ class GetSessionRequest2 : public HttpRequest { public: GetSessionRequest2() : - HttpRequest(REQUEST_GET, STEAM_WEB_URL) + HttpRequest(HttpGet, STEAM_WEB_URL) { flags = NLHRF_HTTP11 | NLHRF_SSL | NLHRF_NODUMP; } -- cgit v1.2.3