GH110: WebSocket accept() fails when Connection header contains multiple tokens

fixed GH #110: WebSocket accept() fails when Connection header contains
multiple tokens
This commit is contained in:
aleks-f 2013-02-26 12:09:14 -06:00
parent 4cb8b78e0f
commit 6d613869cc
3 changed files with 6 additions and 3 deletions

View File

@ -12,6 +12,7 @@ Release 1.5.2 (2013-03-??)
- merged GH #91: Improve SQLite multi-threaded use (by Rangel Reale)
- merged GH #86: Invalid pointers to vector internals (by Adrian Imboden)
- automatic library initialization macros
- fixed GH #110: WebSocket accept() fails when Connection header contains multiple tokens
Release 1.5.1 (2013-01-11)
==========================

View File

@ -47,6 +47,7 @@
#include "Poco/SHA1Engine.h"
#include "Poco/Base64Encoder.h"
#include "Poco/String.h"
#include "Poco/StringTokenizer.h"
#include "Poco/Random.h"
#include "Poco/StreamCopier.h"
#include <sstream>
@ -133,8 +134,8 @@ WebSocket::Mode WebSocket::mode() const
WebSocketImpl* WebSocket::accept(HTTPServerRequest& request, HTTPServerResponse& response)
{
if (icompare(request.get("Connection", ""), "Upgrade") == 0 &&
icompare(request.get("Upgrade", ""), "websocket") == 0)
StringTokenizer st(request.get("Connection", ""), ",", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
if (st.has("Upgrade") && icompare(request.get("Upgrade", ""), "websocket") == 0)
{
std::string version = request.get("Sec-WebSocket-Version", "");
if (version.empty()) throw WebSocketException("Missing Sec-WebSocket-Version in handshake request", WS_ERR_HANDSHAKE_NO_VERSION);

View File

@ -251,7 +251,8 @@ void TCPServerTest::testMultiConnections()
ss5.close();
ss6.close();
Thread::sleep(300);
assert (srv.currentConnections() == 0);}
assert (srv.currentConnections() == 0);
}
void TCPServerTest::setUp()