diff options
Diffstat (limited to 'src/modules/netlib/netlibhttp.cpp')
-rw-r--r-- | src/modules/netlib/netlibhttp.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/src/modules/netlib/netlibhttp.cpp b/src/modules/netlib/netlibhttp.cpp index d1d231d7a3..87e1278f86 100644 --- a/src/modules/netlib/netlibhttp.cpp +++ b/src/modules/netlib/netlibhttp.cpp @@ -109,7 +109,7 @@ static int RecvWithTimeoutTime(NetlibConnection *nlc, unsigned dwTimeoutTime, ch {
DWORD dwTimeNow;
- if ( !si.pending(nlc->hSsl)) {
+ if (!si.pending(nlc->hSsl)) {
while ((dwTimeNow = GetTickCount()) < dwTimeoutTime) {
unsigned dwDeltaTime = min(dwTimeoutTime - dwTimeNow, 1000);
int res = WaitUntilReadable(nlc->s, dwDeltaTime);
@@ -159,9 +159,9 @@ static char* NetlibHttpFindAuthHeader(NETLIBHTTPREQUEST *nlhrReply, const char * }
}
- if (szNegoHdr && ( !szProvider || !_stricmp(szProvider, "Negotiate"))) return szNegoHdr;
- if (szNtlmHdr && ( !szProvider || !_stricmp(szProvider, "NTLM"))) return szNtlmHdr;
- if ( !szProvider || !_stricmp(szProvider, "Basic")) return szBasicHdr;
+ if (szNegoHdr && (!szProvider || !_stricmp(szProvider, "Negotiate"))) return szNegoHdr;
+ if (szNtlmHdr && (!szProvider || !_stricmp(szProvider, "NTLM"))) return szNtlmHdr;
+ if (!szProvider || !_stricmp(szProvider, "Basic")) return szBasicHdr;
return NULL;
}
@@ -204,7 +204,7 @@ static NetlibConnection* NetlibHttpProcessUrl(NETLIBHTTPREQUEST *nlhr, NetlibUse bool httpProxy = !(nloc.flags & NLOCF_SSL) && nlc->proxyType == PROXYTYPE_HTTP;
bool sameHost = lstrcmpA(nlc->nloc.szHost, nloc.szHost) == 0 && nlc->nloc.wPort == nloc.wPort;
- if ( !httpProxy && !sameHost) {
+ if (!httpProxy && !sameHost) {
NetlibDoClose(nlc);
mir_free((char*)nlc->nloc.szHost);
@@ -232,7 +232,7 @@ struct HttpSecurityContext void Destroy(void)
{
- if ( !m_hNtlmSecurity) return;
+ if (!m_hNtlmSecurity) return;
NetlibDestroySecurityProvider(m_hNtlmSecurity);
m_hNtlmSecurity = NULL;
@@ -253,7 +253,7 @@ struct HttpSecurityContext if (m_hNtlmSecurity) {
bool newAuth = !m_szProvider || !szProvider || _stricmp(m_szProvider, szProvider);
- newAuth = newAuth || (m_szHost != szHost && ( !m_szHost || !szHost || _stricmp(m_szHost, szHost)));
+ newAuth = newAuth || (m_szHost != szHost && (!m_szHost || !szHost || _stricmp(m_szHost, szHost)));
if (newAuth)
Destroy();
}
@@ -287,7 +287,7 @@ struct HttpSecurityContext szAuthHdr = NtlmCreateResponseFromChallenge(m_hNtlmSecurity,
szChallenge, szLogin, szPassw, true, complete);
- if ( !szAuthHdr) {
+ if (!szAuthHdr) {
NetlibLogf(NULL, "Security login %s failed, user: %S pssw: %S",
szProvider, szLogin ? szLogin : _T("(no user)"), szPassw ? _T("(exist)") : _T("(no psw)"));
}
@@ -429,8 +429,8 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) return SOCKET_ERROR;
}
- if ( !nlc->usingHttpGateway)
- if ( !NetlibEnterNestedCS(nlc, NLNCS_SEND))
+ if (!nlc->usingHttpGateway)
+ if (!NetlibEnterNestedCS(nlc, NLNCS_SEND))
return SOCKET_ERROR;
const char *pszFullUrl = nlhr->szUrl;
@@ -439,12 +439,12 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) unsigned complete = false;
int count = 11;
while (--count) {
- if ( !NetlibReconnect(nlc)) {
+ if (!NetlibReconnect(nlc)) {
bytesSent = SOCKET_ERROR;
break;
}
- if ( !pszUrl) {
+ if (!pszUrl) {
pszUrl = pszFullUrl;
if (nlhr->flags & (NLHRF_SMARTREMOVEHOST | NLHRF_REMOVEHOST | NLHRF_GENERATEHOST)) {
bool usingProxy = nlc->proxyType == PROXYTYPE_HTTP && !(nlhr->flags & NLHRF_SSL);
@@ -503,11 +503,11 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) doneHostHeader = doneContentLengthHeader = doneProxyAuthHeader = doneAuthHeader = 0;
for (i=0; i < nlhr->headersCount; i++) {
NETLIBHTTPHEADER &p = nlhr->headers[i];
- if ( !lstrcmpiA(p.szName, "Host")) doneHostHeader = 1;
- else if ( !lstrcmpiA(p.szName, "Content-Length")) doneContentLengthHeader = 1;
- else if ( !lstrcmpiA(p.szName, "Proxy-Authorization")) doneProxyAuthHeader = 1;
- else if ( !lstrcmpiA(p.szName, "Authorization")) doneAuthHeader = 1;
- else if ( !lstrcmpiA(p.szName, "Connection")) continue;
+ if (!lstrcmpiA(p.szName, "Host")) doneHostHeader = 1;
+ else if (!lstrcmpiA(p.szName, "Content-Length")) doneContentLengthHeader = 1;
+ else if (!lstrcmpiA(p.szName, "Proxy-Authorization")) doneProxyAuthHeader = 1;
+ else if (!lstrcmpiA(p.szName, "Authorization")) doneAuthHeader = 1;
+ else if (!lstrcmpiA(p.szName, "Connection")) continue;
if (p.szValue == NULL) continue;
AppendToCharBuffer(&httpRequest, "%s: %s\r\n", p.szName, p.szValue);
}
@@ -535,7 +535,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) DWORD fflags = MSG_PEEK | MSG_NODUMP | ((nlhr->flags & NLHRF_NOPROXY) ? MSG_RAW : 0);
DWORD dwTimeOutTime = hdrTimeout < 0 ? -1 : GetTickCount() + hdrTimeout;
- if ( !HttpPeekFirstResponseLine(nlc, dwTimeOutTime, fflags, &nlhr->resultCode, NULL, NULL)) {
+ if (!HttpPeekFirstResponseLine(nlc, dwTimeOutTime, fflags, &nlhr->resultCode, NULL, NULL)) {
NetlibLogf(nlc->nlu, "%s %d: %s Failed (%u %u)", __FILE__, __LINE__, "HttpPeekFirstResponseLine", GetLastError(), count);
DWORD err = GetLastError();
if (err == ERROR_TIMEOUT || err == ERROR_BAD_FORMAT || err == ERROR_BUFFER_OVERFLOW || lastFirstLineFail || nlc->termRequested || nlhr->requestType == REQUEST_CONNECT) {
@@ -613,11 +613,11 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) mir_free(pszAuthHdr); pszAuthHdr = NULL;
if (nlhrReply) {
char *szAuthStr = NULL;
- if ( !complete) {
+ if (!complete) {
szAuthStr = NetlibHttpFindAuthHeader(nlhrReply, "WWW-Authenticate", httpSecurity.m_szProvider);
if (szAuthStr) {
char *szChallenge = strchr(szAuthStr, ' ');
- if ( !szChallenge || !*lrtrimp(szChallenge))
+ if (!szChallenge || !*lrtrimp(szChallenge))
complete = true;
}
}
@@ -647,11 +647,11 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) mir_free(pszProxyAuthHdr); pszProxyAuthHdr = NULL;
if (nlhrReply) {
char *szAuthStr = NULL;
- if ( !complete) {
+ if (!complete) {
szAuthStr = NetlibHttpFindAuthHeader(nlhrReply, "Proxy-Authenticate", httpSecurity.m_szProvider);
if (szAuthStr) {
char *szChallenge = strchr(szAuthStr, ' ');
- if ( !szChallenge || !*lrtrimp(szChallenge + 1))
+ if (!szChallenge || !*lrtrimp(szChallenge + 1))
complete = true;
}
}
@@ -695,7 +695,7 @@ INT_PTR NetlibHttpSendRequest(WPARAM wParam, LPARAM lParam) mir_free(szHost);
mir_free(szNewUrl);
- if ( !nlc->usingHttpGateway)
+ if (!nlc->usingHttpGateway)
NetlibLeaveNestedCS(&nlc->ncsSend);
return bytesSent;
@@ -727,7 +727,7 @@ INT_PTR NetlibHttpFreeRequestStruct(WPARAM, LPARAM lParam) INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam)
{
NetlibConnection *nlc = (struct NetlibConnection*)wParam;
- if ( !NetlibEnterNestedCS(nlc, NLNCS_RECV))
+ if (!NetlibEnterNestedCS(nlc, NLNCS_RECV))
return 0;
char *peol, *pbuffer;
@@ -740,7 +740,7 @@ INT_PTR NetlibHttpRecvHeaders(WPARAM wParam, LPARAM lParam) nlhr->requestType = REQUEST_RESPONSE;
int firstLineLength = 0;
- if ( !HttpPeekFirstResponseLine(nlc, dwRequestTimeoutTime, lParam | MSG_PEEK, &nlhr->resultCode, &nlhr->szResultDescr, &firstLineLength)) {
+ if (!HttpPeekFirstResponseLine(nlc, dwRequestTimeoutTime, lParam | MSG_PEEK, &nlhr->resultCode, &nlhr->szResultDescr, &firstLineLength)) {
NetlibLeaveNestedCS(&nlc->ncsRecv);
NetlibHttpFreeRequestStruct(0, (LPARAM)nlhr);
return 0;
@@ -857,12 +857,12 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) bool doneUserAgentHeader = NetlibHttpFindHeader(nlhr, "User-Agent") != NULL;
bool doneAcceptEncoding = NetlibHttpFindHeader(nlhr, "Accept-Encoding") != NULL;
- if ( !doneUserAgentHeader || !doneAcceptEncoding) {
+ if (!doneUserAgentHeader || !doneAcceptEncoding) {
nlhrSend.headers = (NETLIBHTTPHEADER*)mir_alloc(sizeof(NETLIBHTTPHEADER) * (nlhrSend.headersCount + 2));
memcpy(nlhrSend.headers, nlhr->headers, sizeof(NETLIBHTTPHEADER) * nlhr->headersCount);
}
- if ( !doneUserAgentHeader) {
+ if (!doneUserAgentHeader) {
nlhrSend.headers[nlhrSend.headersCount].szName = "User-Agent";
nlhrSend.headers[nlhrSend.headersCount].szValue = szUserAgent;
++nlhrSend.headersCount;
@@ -876,18 +876,18 @@ INT_PTR NetlibHttpTransaction(WPARAM wParam, LPARAM lParam) }
else mir_snprintf(szUserAgent, SIZEOF(szUserAgent), "Miranda/%s", szMirandaVer);
}
- if ( !doneAcceptEncoding) {
+ if (!doneAcceptEncoding) {
nlhrSend.headers[nlhrSend.headersCount].szName = "Accept-Encoding";
nlhrSend.headers[nlhrSend.headersCount].szValue = "deflate, gzip";
++nlhrSend.headersCount;
}
if (NetlibHttpSendRequest((WPARAM)nlc, (LPARAM)&nlhrSend) == SOCKET_ERROR) {
- if ( !doneUserAgentHeader || !doneAcceptEncoding) mir_free(nlhrSend.headers);
+ if (!doneUserAgentHeader || !doneAcceptEncoding) mir_free(nlhrSend.headers);
nlhr->resultCode = nlhrSend.resultCode;
NetlibCloseHandle((WPARAM)nlc, 0);
return 0;
}
- if ( !doneUserAgentHeader || !doneAcceptEncoding)
+ if (!doneUserAgentHeader || !doneAcceptEncoding)
mir_free(nlhrSend.headers);
dflags = (nlhr->flags & NLHRF_DUMPASTEXT ? MSG_DUMPASTEXT:0) |
@@ -1029,10 +1029,10 @@ next: for (i=0; i<nlhrReply->headersCount; i++) {
NETLIBHTTPHEADER &p = nlhrReply->headers[i];
- if ( !lstrcmpiA(p.szName, "Content-Length"))
+ if (!lstrcmpiA(p.szName, "Content-Length"))
dataLen = atoi(p.szValue);
- if ( !lstrcmpiA(p.szName, "Content-Encoding")) {
+ if (!lstrcmpiA(p.szName, "Content-Encoding")) {
cenc = i;
if (strstr(p.szValue, "gzip"))
cenctype = 1;
@@ -1040,10 +1040,10 @@ next: cenctype = 2;
}
- if ( !lstrcmpiA(p.szName, "Connection"))
+ if (!lstrcmpiA(p.szName, "Connection"))
close = !lstrcmpiA(p.szValue, "close");
- if ( !lstrcmpiA(p.szName, "Transfer-Encoding") &&
+ if (!lstrcmpiA(p.szName, "Transfer-Encoding") &&
!lstrcmpiA(p.szValue, "chunked"))
{
chunked = true;
@@ -1052,7 +1052,7 @@ next: }
}
- if (nlhrReply->resultCode >= 200 && (dataLen > 0 || ( !isConnect && dataLen < 0))) {
+ if (nlhrReply->resultCode >= 200 && (dataLen > 0 || (!isConnect && dataLen < 0))) {
int recvResult, chunksz = -1;
int dataBufferAlloced;
@@ -1161,7 +1161,7 @@ next: if (close &&
(nlc->proxyType != PROXYTYPE_HTTP || nlc->nloc.flags & NLOCF_SSL) &&
- ( !isConnect || nlhrReply->resultCode != 200))
+ (!isConnect || nlhrReply->resultCode != 200))
NetlibDoClose(nlc);
return nlhrReply;
|