From b41249cfae3de49321d23af9e098224a06113796 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 5 Aug 2024 20:22:36 +0300 Subject: =?UTF-8?q?fixes=20#4551=20(SkypeWeb:=20=D0=BD=D0=B5=20=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BE=D1=82=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=B8=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC=20=D1=84=D0=B0=D0=B9=D0=BB=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/SkypeWeb/src/skype_files.cpp | 60 +++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 22 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_files.cpp') diff --git a/protocols/SkypeWeb/src/skype_files.cpp b/protocols/SkypeWeb/src/skype_files.cpp index 24875a5590..a9d6512498 100644 --- a/protocols/SkypeWeb/src/skype_files.cpp +++ b/protocols/SkypeWeb/src/skype_files.cpp @@ -25,30 +25,46 @@ void CSkypeProto::ReceiveFileThread(void *param) ofd->pCallback->Invoke(*ofd); } else { - CMStringA szCookie; + CMStringA szCookie, szUrl; szCookie.AppendFormat("skypetoken_asm=%s", m_szApiToken.get()); + { + MHttpRequest nlhr(REQUEST_GET); + nlhr.flags = NLHRF_HTTP11 | NLHRF_NOUSERAGENT; + nlhr.m_szUrl = blob.getUrl(); + nlhr.m_szUrl += "/views/original/status"; + nlhr.AddHeader("Accept", "*/*"); + nlhr.AddHeader("Accept-Encoding", "gzip, deflate"); + nlhr.AddHeader("Cookie", szCookie); + NLHR_PTR response(Netlib_HttpTransaction(m_hNetlibUser, &nlhr)); + if (response) { + JsonReply reply(response); + if (!reply.error()) { + auto &root = reply.data(); + if (root["view_state"].as_string() == "ready") + szUrl = root["view_location"].as_string().c_str(); + } + } + } - MHttpRequest nlhr(REQUEST_GET); - nlhr.m_szUrl = blob.getUrl(); - nlhr.AddHeader("Sec-Fetch-User", "?1"); - nlhr.AddHeader("Sec-Fetch-Site", "same-site"); - nlhr.AddHeader("Sec-Fetch-Mode", "navigate"); - nlhr.AddHeader("Sec-Fetch-Dest", "empty"); - nlhr.AddHeader("Accept", "*/*"); - nlhr.AddHeader("Accept-Encoding", "gzip"); - nlhr.AddHeader("Cookie", szCookie); - nlhr.AddHeader("Referer", "https://web.skype.com/"); - - NLHR_PTR reply(Netlib_DownloadFile(m_hNetlibUser, &nlhr, ofd->wszPath, DownloadCallack, ofd)); - if (reply && reply->resultCode == 200) { - struct _stat st; - _wstat(ofd->wszPath, &st); - - DBVARIANT dbv = { DBVT_DWORD }; - dbv.dVal = st.st_size; - db_event_setJson(ofd->hDbEvent, "ft", &dbv); - - ofd->Finish(); + if (!szUrl.IsEmpty()) { + MHttpRequest nlhr(REQUEST_GET); + nlhr.flags = NLHRF_HTTP11 | NLHRF_NOUSERAGENT; + nlhr.m_szUrl = szUrl; + nlhr.AddHeader("Accept", "*/*"); + nlhr.AddHeader("Accept-Encoding", "gzip, deflate"); + nlhr.AddHeader("Cookie", szCookie); + + NLHR_PTR reply(Netlib_DownloadFile(m_hNetlibUser, &nlhr, ofd->wszPath, DownloadCallack, ofd)); + if (reply && reply->resultCode == 200) { + struct _stat st; + _wstat(ofd->wszPath, &st); + + DBVARIANT dbv = { DBVT_DWORD }; + dbv.dVal = st.st_size; + db_event_setJson(ofd->hDbEvent, "ft", &dbv); + + ofd->Finish(); + } } } } -- cgit v1.2.3