From e05b5066dd4f0428514ed709e0fe0c81487cb09b Mon Sep 17 00:00:00 2001 From: Tom Finlayson Date: Tue, 28 Jun 2016 09:52:40 +0100 Subject: [PATCH 1/2] Switch to checking if the conenction header contains 'upgrade' rather than equals 'upgrade' --- src/iisnode/cprotocolbridge.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iisnode/cprotocolbridge.cpp b/src/iisnode/cprotocolbridge.cpp index 726758ff..f3ef5356 100644 --- a/src/iisnode/cprotocolbridge.cpp +++ b/src/iisnode/cprotocolbridge.cpp @@ -723,7 +723,7 @@ void CProtocolBridge::SendHttpRequestHeaders(CNodeHttpStoredContext* context) pszConnectionHeader = request->GetHeader(HttpHeaderConnection); if( pszConnectionHeader == NULL || - (pszConnectionHeader != NULL && stricmp(pszConnectionHeader, "upgrade") != 0)) + (pszConnectionHeader != NULL && strstr(pszConnectionHeader, "upgrade") == NULL)) { CheckError(request->SetHeader(HttpHeaderConnection, "keep-alive", 10, TRUE)); } From 855e2b32f5f85b6dcd2428e8b93251013b923171 Mon Sep 17 00:00:00 2001 From: Tom Finlayson Date: Tue, 5 Jul 2016 12:18:56 +0100 Subject: [PATCH 2/2] Tokenize the connection header and check each one for if they are upgrade or not --- src/iisnode/cprotocolbridge.cpp | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/iisnode/cprotocolbridge.cpp b/src/iisnode/cprotocolbridge.cpp index f3ef5356..30e2ebeb 100644 --- a/src/iisnode/cprotocolbridge.cpp +++ b/src/iisnode/cprotocolbridge.cpp @@ -722,11 +722,35 @@ void CProtocolBridge::SendHttpRequestHeaders(CNodeHttpStoredContext* context) request = context->GetHttpContext()->GetRequest(); pszConnectionHeader = request->GetHeader(HttpHeaderConnection); - if( pszConnectionHeader == NULL || + + if (pszConnectionHeader == NULL) { + CheckError(request->SetHeader(HttpHeaderConnection, "keep-alive", 10, TRUE)); + } + else + { + char str2[40]; + strcpy(str2, pszConnectionHeader); + + bool containsUpgrade = false; + char * pch; + pch = strtok(str2, ", "); + while (pch != NULL) + { + containsUpgrade = containsUpgrade || stricmp(pch, "upgrade") == 0; + pch = strtok(NULL, ", "); + } + + if (!containsUpgrade) + { + CheckError(request->SetHeader(HttpHeaderConnection, "keep-alive", 10, TRUE)); + } + } + + /*if( pszConnectionHeader == NULL || (pszConnectionHeader != NULL && strstr(pszConnectionHeader, "upgrade") == NULL)) { CheckError(request->SetHeader(HttpHeaderConnection, "keep-alive", 10, TRUE)); - } + }*/ // Expect: 100-continue has been processed by IIS - do not propagate it up to node.js since node will // attempt to process it again