Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to checking if the conenction header contains 'upgrade' rather than equals 'upgrade' #519

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/iisnode/cprotocolbridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,35 @@ void CProtocolBridge::SendHttpRequestHeaders(CNodeHttpStoredContext* context)
request = context->GetHttpContext()->GetRequest();

pszConnectionHeader = request->GetHeader(HttpHeaderConnection);
if( pszConnectionHeader == NULL ||
(pszConnectionHeader != NULL && stricmp(pszConnectionHeader, "upgrade") != 0))

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
Expand Down