summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-02-07 14:14:38 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-02-07 14:14:38 +0300
commit68d2c9566660c706ec13564ec7bc029cd85a6752 (patch)
tree74bc27454fe01ba358b9e4ff7a8962affb4cbb21 /src/mir_app
parent7d0d9f0db74fbd4750a9c19bd69f4cba368db40e (diff)
MSN was last plugin that used that crap with HTTP Gateways
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/netlib.cpp24
-rw-r--r--src/mir_app/src/netlib.h2
-rw-r--r--src/mir_app/src/netlibautoproxy.cpp4
-rw-r--r--src/mir_app/src/netlibhttp.cpp7
-rw-r--r--src/mir_app/src/netlibhttpproxy.cpp336
-rw-r--r--src/mir_app/src/netlibopenconn.cpp33
-rw-r--r--src/mir_app/src/netlibsock.cpp48
7 files changed, 33 insertions, 421 deletions
diff --git a/src/mir_app/src/netlib.cpp b/src/mir_app/src/netlib.cpp
index 34b2c28440..287bd4f194 100644
--- a/src/mir_app/src/netlib.cpp
+++ b/src/mir_app/src/netlib.cpp
@@ -161,17 +161,12 @@ MIR_APP_DLL(HNETLIBUSER) Netlib_RegisterUser(const NETLIBUSER *nlu)
thisUser->user.szDescriptiveName.w = (thisUser->user.flags & NUF_UNICODE) ? mir_wstrdup(nlu->szDescriptiveName.w) : mir_a2u(nlu->szDescriptiveName.a);
if ((thisUser->user.szSettingsModule = mir_strdup(nlu->szSettingsModule)) == nullptr
- || (nlu->szDescriptiveName.w && thisUser->user.szDescriptiveName.w == nullptr)
- || (nlu->szHttpGatewayUserAgent && (thisUser->user.szHttpGatewayUserAgent = mir_strdup(nlu->szHttpGatewayUserAgent)) == nullptr))
+ || (nlu->szDescriptiveName.w && thisUser->user.szDescriptiveName.w == nullptr))
{
mir_free(thisUser);
SetLastError(ERROR_OUTOFMEMORY);
return nullptr;
}
- if (nlu->szHttpGatewayHello)
- thisUser->user.szHttpGatewayHello = mir_strdup(nlu->szHttpGatewayHello);
- else
- thisUser->user.szHttpGatewayHello = nullptr;
thisUser->settings.cbSize = sizeof(NETLIBUSERSETTINGS);
thisUser->settings.useProxy = GetNetlibUserSettingInt(thisUser->user.szSettingsModule, "NLUseProxy", 0);
@@ -303,8 +298,6 @@ MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE hNetlib)
NetlibFreeUserSettingsStruct(&nlu->settings);
mir_free(nlu->user.szSettingsModule);
mir_free(nlu->user.szDescriptiveName.a);
- mir_free(nlu->user.szHttpGatewayHello);
- mir_free(nlu->user.szHttpGatewayUserAgent);
mir_free(nlu->szStickyHeaders);
}
break;
@@ -314,15 +307,12 @@ MIR_APP_DLL(int) Netlib_CloseHandle(HANDLE hNetlib)
{
NetlibConnection *nlc = (NetlibConnection*)hNetlib;
if (GetNetlibHandleType(nlc) == NLH_CONNECTION) {
- if (nlc->usingHttpGateway)
- HttpGatewayRemovePacket(nlc, -1);
- else {
- if (nlc->s != INVALID_SOCKET)
- NetlibDoCloseSocket(nlc, nlc->termRequested);
- if (nlc->s2 != INVALID_SOCKET)
- closesocket(nlc->s2);
- nlc->s2 = INVALID_SOCKET;
- }
+ if (nlc->s != INVALID_SOCKET)
+ NetlibDoCloseSocket(nlc, nlc->termRequested);
+ if (nlc->s2 != INVALID_SOCKET)
+ closesocket(nlc->s2);
+ nlc->s2 = INVALID_SOCKET;
+
ReleaseMutex(hConnectionHeaderMutex);
HANDLE waitHandles[4] = { hConnectionHeaderMutex, nlc->hOkToCloseEvent, nlc->ncsRecv.hMutex, nlc->ncsSend.hMutex };
diff --git a/src/mir_app/src/netlib.h b/src/mir_app/src/netlib.h
index ae87772fa0..89c67afded 100644
--- a/src/mir_app/src/netlib.h
+++ b/src/mir_app/src/netlib.h
@@ -74,8 +74,6 @@ struct NetlibConnection : public MZeroedObject
int handleType;
SOCKET s, s2;
- bool usingHttpGateway;
- bool usingDirectHttpGateway;
bool proxyAuthNeeded;
bool dnsThroughProxy;
bool termRequested;
diff --git a/src/mir_app/src/netlibautoproxy.cpp b/src/mir_app/src/netlibautoproxy.cpp
index a473fd770a..842ac5234a 100644
--- a/src/mir_app/src/netlibautoproxy.cpp
+++ b/src/mir_app/src/netlibautoproxy.cpp
@@ -80,11 +80,11 @@ bool NetlibGetIeProxyConn(NetlibConnection *nlc, bool forceHttps)
bool usingSsl = false;
char szUrl[1024];
- if ((nlc->nloc.flags & (NLOCF_HTTP | NLOCF_HTTPGATEWAY) && nlc->nloc.flags & NLOCF_SSL) || nlc->nloc.wPort == 443 || forceHttps) {
+ if ((nlc->nloc.flags & NLOCF_HTTP) && (nlc->nloc.flags & NLOCF_SSL) || nlc->nloc.wPort == 443 || forceHttps) {
mir_snprintf(szUrl, "https://%s", nlc->nloc.szHost);
usingSsl = true;
}
- else if (nlc->nloc.flags & (NLOCF_HTTPGATEWAY | NLOCF_HTTP) || nlc->usingHttpGateway)
+ else if ((nlc->nloc.flags & NLOCF_HTTP))
mir_snprintf(szUrl, "http://%s", nlc->nloc.szHost);
else {
strncpy_s(szUrl, nlc->nloc.szHost, _TRUNCATE);
diff --git a/src/mir_app/src/netlibhttp.cpp b/src/mir_app/src/netlibhttp.cpp
index 1131425db1..d29ee6f935 100644
--- a/src/mir_app/src/netlibhttp.cpp
+++ b/src/mir_app/src/netlibhttp.cpp
@@ -404,9 +404,8 @@ MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr
return SOCKET_ERROR;
}
- if (!nlc->usingHttpGateway)
- if (!NetlibEnterNestedCS(nlc, NLNCS_SEND))
- return SOCKET_ERROR;
+ if (!NetlibEnterNestedCS(nlc, NLNCS_SEND))
+ return SOCKET_ERROR;
const char *pszFullUrl = nlhr->szUrl;
const char *pszUrl = nullptr;
@@ -685,7 +684,7 @@ MIR_APP_DLL(int) Netlib_SendHttpRequest(HNETLIBCONN nlc, NETLIBHTTPREQUEST *nlhr
mir_free(szHost);
mir_free(szNewUrl);
- if (nlc && !nlc->usingHttpGateway)
+ if (nlc)
NetlibLeaveNestedCS(&nlc->ncsSend);
return bytesSent;
diff --git a/src/mir_app/src/netlibhttpproxy.cpp b/src/mir_app/src/netlibhttpproxy.cpp
index 506dd23acf..4e0d21e5a4 100644
--- a/src/mir_app/src/netlibhttpproxy.cpp
+++ b/src/mir_app/src/netlibhttpproxy.cpp
@@ -34,321 +34,11 @@ typedef enum
}
RequestType;
-static int HttpGatewayReadSetResult(NetlibConnection *nlc, char *buf, int num, int peek)
-{
- if (nlc->szProxyBuf.GetLength() == 0) return 0;
-
- int bytes = min(num, nlc->szProxyBuf.GetLength());
-
- memcpy(buf, nlc->szProxyBuf, bytes);
- if (!peek)
- nlc->szProxyBuf.Delete(0, bytes);
-
- return bytes;
-}
-
-void HttpGatewayRemovePacket(NetlibConnection *nlc, int pck)
-{
- mir_cslock lck(nlc->csHttpSequenceNums);
- while (pck-- && nlc->pHttpProxyPacketQueue != nullptr) {
- NetlibHTTPProxyPacketQueue *p = nlc->pHttpProxyPacketQueue;
- nlc->pHttpProxyPacketQueue = nlc->pHttpProxyPacketQueue->next;
-
- mir_free(p->dataBuffer);
- mir_free(p);
- }
-}
-
-static bool NetlibHttpGatewaySend(NetlibConnection *nlc, RequestType reqType, const char *buf, int len)
-{
- char szUrl[512];
-
- NETLIBHTTPREQUEST nlhrSend = { 0 };
- nlhrSend.cbSize = sizeof(nlhrSend);
- nlhrSend.nlc = nlc;
- nlhrSend.pData = (char*)buf;
- nlhrSend.dataLength = len;
-
- nlhrSend.flags = NLHRF_DUMPPROXY | NLHRF_NOPROXY | NLHRF_REDIRECT;
- if (nlc->nlhpi.flags & NLHPIF_HTTP11)
- nlhrSend.flags |= NLHRF_HTTP11;
-
- switch (reqType) {
- case reqHelloGet:
- nlhrSend.requestType = REQUEST_GET;
- nlhrSend.szUrl = nlc->nlu->user.szHttpGatewayHello;
- break;
-
- case reqOldGet:
- nlhrSend.requestType = REQUEST_GET;
- nlhrSend.timeout = -1;
- if ((nlc->nlhpi.flags & NLHPIF_USEGETSEQUENCE) && (nlc->nlhpi.szHttpGetUrl != nullptr)) {
- mir_cslock lck(nlc->csHttpSequenceNums);
- mir_snprintf(szUrl, "%s%u", nlc->nlhpi.szHttpGetUrl, nlc->nlhpi.firstGetSequence++);
- if (nlc->nlhpi.flags & NLHPIF_GETPOSTSAMESEQUENCE)
- nlc->nlhpi.firstPostSequence++;
- nlhrSend.szUrl = szUrl;
- }
- else nlhrSend.szUrl = nlc->nlhpi.szHttpGetUrl;
- break;
-
- case reqOldPost:
- nlhrSend.requestType = REQUEST_POST;
- if ((nlc->nlhpi.flags & NLHPIF_USEPOSTSEQUENCE) && (nlc->nlhpi.szHttpPostUrl != nullptr)) {
- mir_snprintf(szUrl, "%s%u", nlc->nlhpi.szHttpPostUrl, nlc->nlhpi.firstPostSequence);
- nlhrSend.szUrl = szUrl;
- }
- else nlhrSend.szUrl = nlc->nlhpi.szHttpPostUrl;
- break;
-
- case reqNewPost:
- nlhrSend.requestType = REQUEST_POST;
- nlhrSend.szUrl = nlc->nlhpi.szHttpPostUrl;
- break;
- }
-
- if (nlc->usingDirectHttpGateway) {
- NETLIBOPENCONNECTION nloc;
- NetlibConnFromUrl(nlhrSend.szUrl, false, nloc);
-
- bool sameHost = mir_strcmp(nlc->nloc.szHost, nloc.szHost) == 0 && nlc->nloc.wPort == nloc.wPort;
- if (!sameHost) {
- NetlibDoCloseSocket(nlc);
-
- mir_free((char*)nlc->nloc.szHost);
- nlc->nloc = nloc;
- if (!NetlibDoConnect(nlc))
- return false;
- }
- else mir_free((char*)nloc.szHost);
- }
-
- nlhrSend.headersCount = 3;
- nlhrSend.headers = (NETLIBHTTPHEADER*)alloca(sizeof(NETLIBHTTPHEADER) * nlhrSend.headersCount);
- nlhrSend.headers[0].szName = "User-Agent";
- nlhrSend.headers[0].szValue = nlc->nlu->user.szHttpGatewayUserAgent;
- nlhrSend.headers[1].szName = "Cache-Control";
- nlhrSend.headers[1].szValue = "no-cache, no-store ";
- nlhrSend.headers[2].szName = "Pragma";
- nlhrSend.headers[2].szValue = "no-cache";
- return Netlib_SendHttpRequest(nlc, &nlhrSend) != SOCKET_ERROR;
-}
-
-static bool NetlibHttpGatewayStdPost(NetlibConnection *nlc, int &numPackets)
-{
- int np = 0, len = 0;
- char *buf;
- NetlibHTTPProxyPacketQueue *p;
- {
- mir_cslock lck(nlc->csHttpSequenceNums);
-
- for (p = nlc->pHttpProxyPacketQueue; p != nullptr && np < nlc->nlhpi.combinePackets; p = p->next) {
- np++;
- len += p->dataBufferLen;
- }
-
- int dlen = 0;
- buf = (char*)alloca(len);
- numPackets = np;
-
- for (p = nlc->pHttpProxyPacketQueue; np--; p = p->next) {
- memcpy(buf + dlen, p->dataBuffer, p->dataBufferLen);
- dlen += p->dataBufferLen;
- }
- }
-
- return NetlibHttpGatewaySend(nlc, reqNewPost, buf, len);
-}
-
-static bool NetlibHttpGatewayOscarPost(NetlibConnection *nlc, const char *buf, int len, int flags)
-{
- NetlibConnection *nlcSend = new NetlibConnection();
- nlcSend->nlu = nlc->nlu;
- nlcSend->nlhpi = nlc->nlhpi;
- nlcSend->s = nlc->s2;
- nlcSend->usingHttpGateway = nlc->usingHttpGateway;
- nlcSend->szProxyServer = nlc->szProxyServer;
- nlcSend->wProxyPort = nlc->wProxyPort;
- nlcSend->proxyType = nlc->proxyType;
- if (!NetlibReconnect(nlcSend)) {
- delete nlcSend;
- return false;
- }
-
- nlc->s2 = nlcSend->s;
-
- bool res = NetlibHttpGatewaySend(nlcSend, reqOldPost, buf, len);
- if (res) {
- NETLIBHTTPREQUEST *nlhrReply = NetlibHttpRecv(nlcSend, flags | MSG_RAW | MSG_DUMPPROXY, MSG_RAW | MSG_DUMPPROXY);
- if (nlhrReply != nullptr) {
- if (nlhrReply->resultCode != 200) {
- NetlibHttpSetLastErrorUsingHttpResult(nlhrReply->resultCode);
- res = false;
- }
- Netlib_FreeHttpRequest(nlhrReply);
- }
- else res = false;
- }
-
- nlc->s2 = nlcSend->s;
- delete nlcSend;
-
- mir_cslock lck(nlc->csHttpSequenceNums);
- nlc->nlhpi.firstPostSequence++;
- if (nlc->nlhpi.flags & NLHPIF_GETPOSTSAMESEQUENCE)
- nlc->nlhpi.firstGetSequence++;
-
- return res;
-}
-
-int NetlibHttpGatewayPost(NetlibConnection *nlc, const char *buf, int len, int flags)
-{
- if (nlc->nlhpi.szHttpGetUrl != nullptr)
- return NetlibHttpGatewayOscarPost(nlc, buf, len, flags) ? len : SOCKET_ERROR;
-
- /*
- * Gena01 - many changes here, do compare against the other version.
- *
- * Change #1: simplify to use similar code to GET
- * Change #2: we need to allow to parse POST reply if szHttpGetUrl is nullptr
- * Change #3: Keep connection open if we need to.
- *
- * Impact: NONE! Since currently miranda doesn't allow szHttpGetUrl to be nullptr, it will not connect
- * with the new plugins that use this code.
- */
-
- NetlibHTTPProxyPacketQueue *p = (NetlibHTTPProxyPacketQueue*)mir_alloc(sizeof(struct NetlibHTTPProxyPacketQueue));
- p->dataBuffer = (PBYTE)mir_alloc(len);
- memcpy(p->dataBuffer, buf, len);
- p->dataBufferLen = len;
- p->next = nullptr;
-
- // Now check to see where to insert this in our queue
- mir_cslock lck(nlc->csHttpSequenceNums);
- if (nlc->pHttpProxyPacketQueue == nullptr)
- nlc->pHttpProxyPacketQueue = p;
- else {
- NetlibHTTPProxyPacketQueue *t = nlc->pHttpProxyPacketQueue;
- while (t->next != nullptr)
- t = t->next;
- t->next = p;
- }
-
- return len;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
#define NETLIBHTTP_RETRYCOUNT 3
#define NETLIBHTTP_RETRYTIMEOUT 2000
-int NetlibHttpGatewayRecv(NetlibConnection *nlc, char *buf, int len, int flags)
-{
- bool peek = (flags & MSG_PEEK) != 0;
-
- if (nlc->szProxyBuf.GetLength() != 0 && (!peek || nlc->szProxyBuf.GetLength() >= len))
- return HttpGatewayReadSetResult(nlc, buf, len, peek);
-
- NetlibUser *nlu = nlc->nlu;
- if (GetNetlibHandleType(nlu) != NLH_USER)
- return SOCKET_ERROR;
-
- for (int retryCount = 0; retryCount < NETLIBHTTP_RETRYCOUNT;) {
- if (nlc->nlhpi.szHttpGetUrl == nullptr && retryCount == 0) {
- if (nlc->pollingTimeout == 0) nlc->pollingTimeout = 30;
-
- /* We Need to sleep/wait for the data to send before we do receive */
- for (int pollCount = nlc->pollingTimeout; pollCount--;) {
- if (nlc->pHttpProxyPacketQueue != nullptr && GetTickCount() - nlc->lastPost > 1000)
- break;
-
- if (nlc->termRequested || (SleepEx(1000, TRUE) && Miranda_IsTerminated()))
- return SOCKET_ERROR;
- }
-
- nlc->lastPost = GetTickCount();
- if (nlc->pHttpProxyPacketQueue == nullptr && nlu->user.pfnHttpGatewayWrapSend != nullptr)
- if (nlu->user.pfnHttpGatewayWrapSend(nlc, (PBYTE)"", 0, MSG_NOHTTPGATEWAYWRAP) == SOCKET_ERROR)
- return SOCKET_ERROR;
- }
-
- int numPackets = 0;
- if (nlc->nlhpi.szHttpGetUrl) {
- if (!NetlibHttpGatewaySend(nlc, reqOldGet, nullptr, 0)) {
- if (GetLastError() == ERROR_ACCESS_DENIED || nlc->termRequested)
- break;
-
- ++retryCount;
- continue;
- }
- }
- else {
- if (!NetlibHttpGatewayStdPost(nlc, numPackets)) {
- if (GetLastError() == ERROR_ACCESS_DENIED || nlc->termRequested)
- break;
-
- ++retryCount;
- continue;
- }
- }
- NETLIBHTTPREQUEST *nlhrReply = NetlibHttpRecv(nlc, flags | MSG_RAW | MSG_DUMPPROXY, MSG_RAW | MSG_DUMPPROXY);
- if (nlhrReply == nullptr)
- return SOCKET_ERROR;
-
- if (nlu->user.pfnHttpGatewayUnwrapRecv && !(flags & MSG_NOHTTPGATEWAYWRAP))
- nlhrReply->pData = (char*)nlu->user.pfnHttpGatewayUnwrapRecv(nlhrReply, (PBYTE)nlhrReply->pData, nlhrReply->dataLength, &nlhrReply->dataLength, mir_realloc);
-
- if (nlhrReply->resultCode >= 300) {
- int resultCode = nlhrReply->resultCode;
- Netlib_FreeHttpRequest(nlhrReply);
-
- if (nlc->nlhpi.szHttpGetUrl && resultCode != 404) {
- Netlib_Logf(nlu, "Error received from proxy, retrying");
- continue;
- }
- else {
- Netlib_Logf(nlu, "Error received from proxy, retry attempts exceeded (%u)", retryCount);
- SetLastError(ERROR_GEN_FAILURE);
- return SOCKET_ERROR;
- }
- }
- else {
- retryCount = 0;
- HttpGatewayRemovePacket(nlc, numPackets);
- }
-
- if (nlhrReply->dataLength) {
- if (peek) {
- nlc->szProxyBuf.Append(nlhrReply->pData, nlhrReply->dataLength);
- Netlib_FreeHttpRequest(nlhrReply);
- return HttpGatewayReadSetResult(nlc, buf, len, peek);
- }
-
- int bytes = min(len, nlhrReply->dataLength);
-
- memcpy(buf, nlhrReply->pData, bytes);
-
- if (nlhrReply->dataLength > bytes)
- nlc->szProxyBuf.SetString(nlhrReply->pData + bytes, nlhrReply->dataLength - bytes);
- else
- nlc->szProxyBuf.Empty();
-
- Netlib_FreeHttpRequest(nlhrReply);
- return bytes;
- }
- else {
- if ((peek && nlc->szProxyBuf.GetLength() != 0) || nlhrReply->pData) {
- Netlib_FreeHttpRequest(nlhrReply);
- return HttpGatewayReadSetResult(nlc, buf, len, peek);
- }
- }
- Netlib_FreeHttpRequest(nlhrReply);
- }
-
- SetLastError(ERROR_GEN_FAILURE);
- return SOCKET_ERROR;
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
int NetlibInitHttpConnection(HNETLIBCONN nlc, NetlibUser *nlu, NETLIBOPENCONNECTION *nloc)
@@ -360,36 +50,12 @@ int NetlibInitHttpConnection(HNETLIBCONN nlc, NetlibUser *nlu, NETLIBOPENCONNECT
nlc->nlhpi.firstPostSequence = 1;
}
- if (nlu->user.szHttpGatewayHello != nullptr) {
- nlc->usingHttpGateway = true;
- if (NetlibHttpGatewaySend(nlc, reqHelloGet, nullptr, 0))
- nlhrReply = NetlibHttpRecv(nlc, MSG_DUMPPROXY | MSG_RAW, MSG_DUMPPROXY | MSG_RAW);
- nlc->usingHttpGateway = false;
- if (nlhrReply == nullptr) return 0;
-
- if (nlhrReply->resultCode != 200) {
- NetlibHttpSetLastErrorUsingHttpResult(nlhrReply->resultCode);
- Netlib_FreeHttpRequest(nlhrReply);
- return 0;
- }
- }
- if (!nlu->user.pfnHttpGatewayInit(nlc, nloc, nlhrReply)) {
- Netlib_FreeHttpRequest(nlhrReply);
- return 0;
- }
- Netlib_FreeHttpRequest(nlhrReply);
-
if (nlc->nlhpi.szHttpPostUrl == nullptr) {
SetLastError(ERROR_BAD_FORMAT);
return 0;
}
- nlc->usingHttpGateway = true;
-
- //now properly connected
- if (nlu->user.pfnHttpGatewayBegin && !nlu->user.pfnHttpGatewayBegin(nlc, nloc))
- return 0;
-
+ // now properly connected
return 1;
}
diff --git a/src/mir_app/src/netlibopenconn.cpp b/src/mir_app/src/netlibopenconn.cpp
index 28061dac06..52758ab3fd 100644
--- a/src/mir_app/src/netlibopenconn.cpp
+++ b/src/mir_app/src/netlibopenconn.cpp
@@ -310,15 +310,10 @@ static bool NetlibInitHttpsConnection(NetlibConnection *nlc, NetlibUser *nlu, NE
nlhrSend.flags = NLHRF_DUMPPROXY | NLHRF_HTTP11 | NLHRF_NOPROXY | NLHRF_REDIRECT;
nlhrSend.szUrl = szUrl.GetBuffer();
- nlc->usingHttpGateway = true;
-
- if (Netlib_SendHttpRequest(nlc, &nlhrSend) == SOCKET_ERROR) {
- nlc->usingHttpGateway = false;
+ if (Netlib_SendHttpRequest(nlc, &nlhrSend) == SOCKET_ERROR)
return false;
- }
NETLIBHTTPREQUEST *nlhrReply = NetlibHttpRecv(nlc, MSG_DUMPPROXY | MSG_RAW, MSG_DUMPPROXY | MSG_RAW, true);
- nlc->usingHttpGateway = false;
if (nlhrReply == nullptr)
return false;
@@ -735,6 +730,7 @@ bool NetlibDoConnect(NetlibConnection *nlc)
break;
case PROXYTYPE_HTTPS:
+ case PROXYTYPE_HTTP:
nlc->proxyAuthNeeded = true;
if (!NetlibInitHttpsConnection(nlc, nlu, nloc)) {
usingProxy = false;
@@ -743,33 +739,12 @@ bool NetlibDoConnect(NetlibConnection *nlc)
}
break;
- case PROXYTYPE_HTTP:
- nlc->proxyAuthNeeded = true;
- if (!(nloc->flags & NLOCF_HTTPGATEWAY) || nloc->flags & NLOCF_SSL) {
- // NLOCF_HTTP not specified and no HTTP gateway available: try HTTPS
- if (!NetlibInitHttpsConnection(nlc, nlu, nloc)) {
- // can't do HTTPS: try direct
- usingProxy = false;
- if (!NetlibHttpFallbackToDirect(nlc, nlu, nloc))
- return false;
- }
- }
- else if (!NetlibInitHttpConnection(nlc, nlu, nloc))
- return false;
-
- break;
-
default:
SetLastError(ERROR_INVALID_PARAMETER);
FreePartiallyInitedConnection(nlc);
return false;
}
}
- else if (nloc->flags & NLOCF_HTTPGATEWAY) {
- if (!NetlibInitHttpConnection(nlc, nlu, nloc))
- return false;
- nlc->usingDirectHttpGateway = true;
- }
Netlib_Logf(nlu, "(%d) Connected to %s:%d", nlc->s, nloc->szHost, nloc->wPort);
@@ -830,10 +805,6 @@ bool NetlibReconnect(NetlibConnection *nlc)
if (Miranda_IsTerminated())
return false;
- if (nlc->usingHttpGateway) {
- nlc->proxyAuthNeeded = true;
- return my_connect(nlc, &nlc->nloc);
- }
return NetlibDoConnect(nlc);
}
return true;
diff --git a/src/mir_app/src/netlibsock.cpp b/src/mir_app/src/netlibsock.cpp
index a09298aced..a2cbfbe5a1 100644
--- a/src/mir_app/src/netlibsock.cpp
+++ b/src/mir_app/src/netlibsock.cpp
@@ -35,20 +35,12 @@ MIR_APP_DLL(int) Netlib_Send(HNETLIBCONN nlc, const char *buf, int len, int flag
return SOCKET_ERROR;
int result;
- if (nlc->usingHttpGateway && !(flags & MSG_RAW)) {
- if (!(flags & MSG_NOHTTPGATEWAYWRAP) && nlc->nlu->user.pfnHttpGatewayWrapSend) {
- NetlibDumpData(nlc, (PBYTE)buf, len, 1, flags);
- result = nlc->nlu->user.pfnHttpGatewayWrapSend(nlc, (PBYTE)buf, len, flags | MSG_NOHTTPGATEWAYWRAP);
- }
- else result = NetlibHttpGatewayPost(nlc, buf, len, flags);
- }
- else {
- NetlibDumpData(nlc, (PBYTE)buf, len, 1, flags);
- if (nlc->hSsl)
- result = sslApi.write(nlc->hSsl, buf, len);
- else
- result = send(nlc->s, buf, len, flags & 0xFFFF);
- }
+ NetlibDumpData(nlc, (PBYTE)buf, len, 1, flags);
+ if (nlc->hSsl)
+ result = sslApi.write(nlc->hSsl, buf, len);
+ else
+ result = send(nlc->s, buf, len, flags & 0xFFFF);
+
NetlibLeaveNestedCS(&nlc->ncsSend);
NETLIBNOTIFY nln = { buf, len, flags, result };
@@ -65,19 +57,16 @@ MIR_APP_DLL(int) Netlib_Recv(HNETLIBCONN nlc, char *buf, int len, int flags)
return SOCKET_ERROR;
int recvResult;
- if (nlc->usingHttpGateway && !(flags & MSG_RAW))
- recvResult = NetlibHttpGatewayRecv(nlc, buf, len, flags);
- else {
- if (!nlc->foreBuf.isEmpty()) {
- recvResult = min(len, (int)nlc->foreBuf.length());
- memcpy(buf, nlc->foreBuf.data(), recvResult);
- nlc->foreBuf.remove(recvResult);
- }
- else if (nlc->hSsl)
- recvResult = sslApi.read(nlc->hSsl, buf, len, (flags & MSG_PEEK) != 0);
- else
- recvResult = recv(nlc->s, buf, len, flags & 0xFFFF);
+ if (!nlc->foreBuf.isEmpty()) {
+ recvResult = min(len, (int)nlc->foreBuf.length());
+ memcpy(buf, nlc->foreBuf.data(), recvResult);
+ nlc->foreBuf.remove(recvResult);
}
+ else if (nlc->hSsl)
+ recvResult = sslApi.read(nlc->hSsl, buf, len, (flags & MSG_PEEK) != 0);
+ else
+ recvResult = recv(nlc->s, buf, len, flags & 0xFFFF);
+
NetlibLeaveNestedCS(&nlc->ncsRecv);
if (recvResult <= 0)
return recvResult;
@@ -173,16 +162,15 @@ MIR_APP_DLL(int) Netlib_SelectEx(NETLIBSELECTEX *nls)
if (sslApi.pending(conn->hSsl))
nls->hReadStatus[j] = TRUE;
- if (conn->usingHttpGateway && conn->nlhpi.szHttpGetUrl == nullptr && conn->szProxyBuf.IsEmpty())
- nls->hReadStatus[j] = (conn->pHttpProxyPacketQueue != nullptr);
- else
- nls->hReadStatus[j] = FD_ISSET(conn->s, &readfd);
+ nls->hReadStatus[j] = FD_ISSET(conn->s, &readfd);
}
+
for (j = 0; j < FD_SETSIZE; j++) {
conn = (NetlibConnection*)nls->hWriteConns[j];
if (conn == nullptr || conn == INVALID_HANDLE_VALUE) break;
nls->hWriteStatus[j] = FD_ISSET(conn->s, &writefd);
}
+
for (j = 0; j < FD_SETSIZE; j++) {
conn = (NetlibConnection*)nls->hExceptConns[j];
if (conn == nullptr || conn == INVALID_HANDLE_VALUE) break;