summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-01-09 14:46:44 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-01-09 14:46:44 +0300
commit43a25d3f11edcc5fbb9dbba1662bbaae92e005ab (patch)
treed2273ea6016b30fdac2c64e6308c63e8d93ead4d
parent43d54b4b589faa36f74c815725fd64c18258448e (diff)
code cleaning
-rw-r--r--src/mir_app/src/netlib_autoproxy.cpp2
-rw-r--r--src/mir_app/src/netlib_websocket.cpp28
2 files changed, 14 insertions, 16 deletions
diff --git a/src/mir_app/src/netlib_autoproxy.cpp b/src/mir_app/src/netlib_autoproxy.cpp
index f030b76f2f..e20577b02d 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(0);
+ MHttpRequest nlhr(REQUEST_GET);
nlhr.flags = NLHRF_HTTP11 | NLHRF_DUMPASTEXT | NLHRF_REDIRECT;
nlhr.m_szUrl = szUrl;
diff --git a/src/mir_app/src/netlib_websocket.cpp b/src/mir_app/src/netlib_websocket.cpp
index 1bd8f2e4cd..ab676b7a6a 100644
--- a/src/mir_app/src/netlib_websocket.cpp
+++ b/src/mir_app/src/netlib_websocket.cpp
@@ -35,28 +35,26 @@ 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(0);
- nlr->flags = NLHRF_PERSISTENT | NLHRF_HTTP11 | NLHRF_SSL;
- nlr->m_szUrl = tmpHost.GetBuffer();
- nlr->AddHeader("Accept", "*/*");
- nlr->AddHeader("Upgrade", "websocket");
- nlr->AddHeader("Pragma", "no-cache");
- nlr->AddHeader("Cache-Control", "no-cache");
- nlr->AddHeader("Connection", "keep-alive, Upgrade");
+ MHttpRequest nlhr(REQUEST_GET);
+ nlhr.flags = NLHRF_PERSISTENT | NLHRF_HTTP11 | NLHRF_SSL;
+ nlhr.m_szUrl = tmpHost.GetBuffer();
+ nlhr.AddHeader("Accept", "*/*");
+ nlhr.AddHeader("Upgrade", "websocket");
+ nlhr.AddHeader("Pragma", "no-cache");
+ nlhr.AddHeader("Cache-Control", "no-cache");
+ nlhr.AddHeader("Connection", "keep-alive, Upgrade");
uint8_t binNonce[16];
Utils_GetRandom(binNonce, sizeof(binNonce));
- nlr->AddHeader("Sec-WebSocket-Key", ptrA(mir_base64_encode(binNonce, sizeof(binNonce))));
- nlr->AddHeader("Sec-WebSocket-Version", "13");
- nlr->AddHeader("Sec-WebSocket-Extensions", "permessage-deflate; client_max_window_bits");
+ nlhr.AddHeader("Sec-WebSocket-Key", ptrA(mir_base64_encode(binNonce, sizeof(binNonce))));
+ nlhr.AddHeader("Sec-WebSocket-Version", "13");
+ nlhr.AddHeader("Sec-WebSocket-Extensions", "permessage-deflate; client_max_window_bits");
if (pHeaders)
for (auto &it: *pHeaders)
- nlr->AddHeader(it->szName, it->szValue);
-
- auto *pReply = Netlib_HttpTransaction(nlu, nlr);
- delete nlr;
+ nlhr.AddHeader(it->szName, it->szValue);
+ auto *pReply = Netlib_HttpTransaction(nlu, &nlhr);
if (pReply == nullptr) {
Netlib_Logf(nlu, "Error establishing WebSocket connection to %s, send failed", tmpHost.c_str());
return nullptr;