diff options
author | George Hazan <ghazan@miranda.im> | 2020-01-13 16:48:55 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2020-01-13 16:48:55 +0300 |
commit | 87a2660299edd64cbb6f6c92c33683e91a6d187c (patch) | |
tree | a1b0777ec5b8afc0c49fbb66cf6a122b5ac82c6d /protocols/SkypeWeb | |
parent | 21f52dbfa251d171b4cc9dc315e8736da2e2be08 (diff) |
Netlib_GetHeader() - handful utility to avoid writing cycles
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r-- | protocols/SkypeWeb/src/skype_mslogin.cpp | 15 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_oauth.cpp | 7 |
2 files changed, 6 insertions, 16 deletions
diff --git a/protocols/SkypeWeb/src/skype_mslogin.cpp b/protocols/SkypeWeb/src/skype_mslogin.cpp index 4846ae6243..30272829f7 100644 --- a/protocols/SkypeWeb/src/skype_mslogin.cpp +++ b/protocols/SkypeWeb/src/skype_mslogin.cpp @@ -39,12 +39,9 @@ void CSkypeProto::OnMSLoginFirst(const NETLIBHTTPREQUEST *response) }
std::string PPTF = match[1];
- for (int i = 0; i < response->headersCount; i++) {
- if (mir_strcmpi(response->headers[i].szName, "Set-Cookie"))
- continue;
-
+ if (auto *pszHdr = Netlib_GetHeader(response, "Set-Cookie")) {
regex = "^(.+?)=(.+?);";
- content = response->headers[i].szValue;
+ content = pszHdr;
if (std::regex_search(content, match, regex))
scookies[match[1]] = match[2];
}
@@ -71,12 +68,9 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response) if (std::regex_search(content, match, regex)) {
if (match[1] == "i5600") {
CMStringA szCookies;
- for (int i = 0; i < response->headersCount; i++) {
- if (mir_strcmpi(response->headers[i].szName, "Set-Cookie"))
- continue;
-
+ if (auto *pszHdr = Netlib_GetHeader(response, "Set-Cookie")) {
regex = "^(.+?)=(.+?);";
- content = response->headers[i].szValue;
+ content = pszHdr;
if (std::regex_search(content, match, regex))
if (!std::string(match[2]).empty() && std::string(match[2]) != " ")
szCookies.AppendFormat("%s=%s;", std::string(match[1]).c_str(), std::string(match[2]).c_str());
@@ -85,7 +79,6 @@ void CSkypeProto::OnMSLoginSecond(const NETLIBHTTPREQUEST *response) CMStringA url(GetStringChunk(szContent, "urlPost:'", "'"));
CMStringA ppft(GetStringChunk(szContent, "sFT:'", "'"));
-
ptrA code(mir_utf8encodeW(RunConfirmationCode()));
SendRequest(new LoginMSRequest(url.c_str(), ptrA(getStringA(SKYPE_SETTINGS_ID)), szCookies.c_str(), ppft.c_str(), code), &CSkypeProto::OnMSLoginEnd);
diff --git a/protocols/SkypeWeb/src/skype_oauth.cpp b/protocols/SkypeWeb/src/skype_oauth.cpp index d00fc7fa10..dcb087322b 100644 --- a/protocols/SkypeWeb/src/skype_oauth.cpp +++ b/protocols/SkypeWeb/src/skype_oauth.cpp @@ -39,12 +39,9 @@ void CSkypeProto::OnOAuthStart(const NETLIBHTTPREQUEST *response) } std::string PPTF = match[1]; - for (int i = 0; i < response->headersCount; i++) { - if (mir_strcmpi(response->headers[i].szName, "Set-Cookie")) - continue; - + if (auto *pszHdr = Netlib_GetHeader(response, "Set-Cookie")) { regex = "^(.+?)=(.+?);"; - content = response->headers[i].szValue; + content = pszHdr; if (std::regex_search(content, match, regex)) scookies[match[1]] = match[2]; } |