wsd: improved getErrorCode
Change-Id: I89b36b5e69cbbe05ac7b1730633d695bc5185823 Reviewed-on: https://gerrit.libreoffice.org/33117 Reviewed-by: Ashod Nakashian <ashnakash@gmail.com> Tested-by: Ashod Nakashian <ashnakash@gmail.com>
This commit is contained in:
parent
e0dcc7a972
commit
8cbf478bfe
2 changed files with 8 additions and 8 deletions
|
@ -162,7 +162,7 @@ std::string const & getTestServerURI()
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
int getErrorCode(LOOLWebSocket& ws, std::string& message)
|
int getErrorCode(LOOLWebSocket& ws, std::string& message, const std::string& testname = "")
|
||||||
{
|
{
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
|
@ -170,13 +170,13 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
|
||||||
Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
|
Poco::Buffer<char> buffer(READ_BUFFER_SIZE);
|
||||||
|
|
||||||
message.clear();
|
message.clear();
|
||||||
Poco::Timespan timeout(5000000);
|
ws.setReceiveTimeout(Poco::Timespan(5000000));
|
||||||
ws.setReceiveTimeout(timeout);
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bytes = ws.receiveFrame(buffer.begin(), READ_BUFFER_SIZE, flags);
|
bytes = ws.receiveFrame(buffer.begin(), READ_BUFFER_SIZE, flags);
|
||||||
|
std::cerr << testname << "Got " << LOOLProtocol::getAbbreviatedFrameDump(buffer.begin(), bytes, flags) << std::endl;
|
||||||
}
|
}
|
||||||
while ((flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
|
while (bytes > 0 && (flags & Poco::Net::WebSocket::FRAME_OP_BITMASK) != Poco::Net::WebSocket::FRAME_OP_CLOSE);
|
||||||
|
|
||||||
if (bytes > 0)
|
if (bytes > 0)
|
||||||
{
|
{
|
||||||
|
@ -189,9 +189,9 @@ int getErrorCode(LOOLWebSocket& ws, std::string& message)
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
int getErrorCode(const std::shared_ptr<LOOLWebSocket>& ws, std::string& message)
|
int getErrorCode(const std::shared_ptr<LOOLWebSocket>& ws, std::string& message, const std::string& testname = "")
|
||||||
{
|
{
|
||||||
return getErrorCode(*ws, message);
|
return getErrorCode(*ws, message, testname);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
|
|
@ -116,7 +116,7 @@ void HTTPWSError::testMaxDocuments()
|
||||||
assertResponseString(socket, "error:", testname);
|
assertResponseString(socket, "error:", testname);
|
||||||
|
|
||||||
std::string message;
|
std::string message;
|
||||||
const auto statusCode = getErrorCode(socket, message);
|
const auto statusCode = getErrorCode(socket, message, testname);
|
||||||
CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode);
|
CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode);
|
||||||
|
|
||||||
socket->shutdown();
|
socket->shutdown();
|
||||||
|
@ -171,7 +171,7 @@ void HTTPWSError::testMaxConnections()
|
||||||
sendTextFrame(socketN, "load url=" + docURL, testname);
|
sendTextFrame(socketN, "load url=" + docURL, testname);
|
||||||
|
|
||||||
std::string message;
|
std::string message;
|
||||||
const auto statusCode = getErrorCode(socketN, message);
|
const auto statusCode = getErrorCode(socketN, message, testname);
|
||||||
CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode);
|
CPPUNIT_ASSERT_EQUAL(static_cast<int>(Poco::Net::WebSocket::WS_POLICY_VIOLATION), statusCode);
|
||||||
|
|
||||||
socketN->shutdown();
|
socketN->shutdown();
|
||||||
|
|
Loading…
Reference in a new issue