summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-08-05 20:22:36 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-08-05 20:22:36 +0300
commitb41249cfae3de49321d23af9e098224a06113796 (patch)
tree76adda8193edc91c884c0bad8c5c0b10d9877a60
parent4f14f0cbdb82962e84716a118e6e0fb78f855c8b (diff)
fixes #4551 (SkypeWeb: не работает отправка и прием файлов)
-rw-r--r--include/m_netlib.h1
-rw-r--r--protocols/SkypeWeb/src/request_queue.cpp1
-rw-r--r--protocols/SkypeWeb/src/skype_files.cpp60
-rw-r--r--src/mir_app/src/netlib_http.cpp2
4 files changed, 40 insertions, 24 deletions
diff --git a/include/m_netlib.h b/include/m_netlib.h
index 36f48ed67f..ad93fb4048 100644
--- a/include/m_netlib.h
+++ b/include/m_netlib.h
@@ -413,6 +413,7 @@ EXTERN_C MIR_APP_DLL(NETLIBIPLIST*) Netlib_GetMyIp(bool bGlobalOnly);
#define REQUEST_PATCH 7
#define NLHRF_MANUALHOST 0x00000001 // do not remove any host and/or protocol portion of szUrl before sending it
+#define NLHRF_NOUSERAGENT 0x00000002 // skip automatic user agent substitution
#define NLHRF_HTTP11 0x00000010 // use HTTP 1.1
#define NLHRF_PERSISTENT 0x00000020 // preserve connection on exit, open connection provided in the nlc field of the reply
// it should be supplied in nlc field of request for reuse or closed if not needed
diff --git a/protocols/SkypeWeb/src/request_queue.cpp b/protocols/SkypeWeb/src/request_queue.cpp
index 39dc13b8aa..e4cf75669c 100644
--- a/protocols/SkypeWeb/src/request_queue.cpp
+++ b/protocols/SkypeWeb/src/request_queue.cpp
@@ -122,7 +122,6 @@ MHttpResponse* CSkypeProto::DoSend(AsyncHttpRequest *pReq)
break;
}
- pReq->m_szUrl = pReq->m_szUrl.GetBuffer();
debugLogA("Send request to %s", pReq->m_szUrl.c_str());
return Netlib_HttpTransaction(m_hNetlibUser, pReq);
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();
+ }
}
}
}
diff --git a/src/mir_app/src/netlib_http.cpp b/src/mir_app/src/netlib_http.cpp
index c05b02488f..ee05831d17 100644
--- a/src/mir_app/src/netlib_http.cpp
+++ b/src/mir_app/src/netlib_http.cpp
@@ -1053,7 +1053,7 @@ static MHttpResponse* HttpTransactionWorker(HNETLIBUSER nlu, MHttpRequest *nlhr,
nlhr->m_szParam.Empty();
}
- if (!nlhr->FindHeader("User-Agent")) {
+ if (!nlhr->FindHeader("User-Agent") && !(nlhr->flags & NLHRF_NOUSERAGENT)) {
char szUserAgent[64], szMirandaVer[64];
strncpy_s(szMirandaVer, MIRANDA_VERSION_STRING, _TRUNCATE);
#if defined(_WIN64)