mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
porting 1.4.4 rev. 1929, 1939 (SF# 3552680 et. al)
This commit is contained in:
parent
91b3ca4421
commit
ae45a2d311
@ -171,6 +171,8 @@ class AbstractEvent
|
|||||||
/// to create the PriorityDelegate.
|
/// to create the PriorityDelegate.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef TArgs Args;
|
||||||
|
|
||||||
AbstractEvent():
|
AbstractEvent():
|
||||||
_executeAsync(this, &AbstractEvent::executeAsyncImpl),
|
_executeAsync(this, &AbstractEvent::executeAsyncImpl),
|
||||||
_enabled(true)
|
_enabled(true)
|
||||||
|
@ -42,15 +42,19 @@
|
|||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#if POCO_OS == POCO_OS_WINDOWS_NT
|
#if POCO_OS == POCO_OS_WINDOWS_NT
|
||||||
#include "Poco/UnWindows.h"
|
#include "Poco/UnWindows.h"
|
||||||
#elif POCO_OS == POCO_OS_MAC_OS_X
|
#elif POCO_OS == POCO_OS_MAC_OS_X
|
||||||
#include <libkern/OSAtomic.h>
|
#include <libkern/OSAtomic.h>
|
||||||
#elif ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 1) || __GNUC__ > 4) && (defined(__x86_64__) || defined(__i386__))
|
#elif ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2) || __GNUC__ > 4) && (defined(__x86_64__) || defined(__i386__))
|
||||||
#if !defined(POCO_HAVE_GCC_ATOMICS)
|
#if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS)
|
||||||
#define POCO_HAVE_GCC_ATOMICS
|
#define POCO_HAVE_GCC_ATOMICS
|
||||||
#endif
|
#endif
|
||||||
|
#elif ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) || __GNUC__ > 4)
|
||||||
|
#if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS)
|
||||||
|
#define POCO_HAVE_GCC_ATOMICS
|
||||||
|
#endif
|
||||||
#else
|
#else
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#endif // POCO_OS
|
#endif // POCO_OS
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,7 +122,12 @@ public:
|
|||||||
/// Specify 0 for unlimited (not recommended).
|
/// Specify 0 for unlimited (not recommended).
|
||||||
///
|
///
|
||||||
/// The default limit is 100.
|
/// The default limit is 100.
|
||||||
|
|
||||||
|
bool hasToken(const std::string& fieldName, const std::string& token) const;
|
||||||
|
/// Returns true iff the field with the given fieldName contains
|
||||||
|
/// the given token. Tokens in a header field are expected to be
|
||||||
|
/// comma-separated and are case insensitive.
|
||||||
|
|
||||||
static void splitElements(const std::string& s, std::vector<std::string>& elements, bool ignoreEmpty = true);
|
static void splitElements(const std::string& s, std::vector<std::string>& elements, bool ignoreEmpty = true);
|
||||||
/// Splits the given string into separate elements. Elements are expected
|
/// Splits the given string into separate elements. Elements are expected
|
||||||
/// to be separated by commas.
|
/// to be separated by commas.
|
||||||
|
@ -139,6 +139,20 @@ void MessageHeader::setFieldLimit(int limit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool MessageHeader::hasToken(const std::string& fieldName, const std::string& token) const
|
||||||
|
{
|
||||||
|
std::string field = get(fieldName, "");
|
||||||
|
std::vector<std::string> tokens;
|
||||||
|
splitElements(field, tokens, true);
|
||||||
|
for (std::vector<std::string>::const_iterator it = tokens.begin(); it != tokens.end(); ++it)
|
||||||
|
{
|
||||||
|
if (Poco::icompare(*it, token) == 0)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MessageHeader::splitElements(const std::string& s, std::vector<std::string>& elements, bool ignoreEmpty)
|
void MessageHeader::splitElements(const std::string& s, std::vector<std::string>& elements, bool ignoreEmpty)
|
||||||
{
|
{
|
||||||
elements.clear();
|
elements.clear();
|
||||||
|
@ -118,9 +118,28 @@ int WebSocketImpl::sendBytes(const void* buffer, int length, int flags)
|
|||||||
int WebSocketImpl::receiveBytes(void* buffer, int length, int)
|
int WebSocketImpl::receiveBytes(void* buffer, int length, int)
|
||||||
{
|
{
|
||||||
char header[MAX_HEADER_LENGTH];
|
char header[MAX_HEADER_LENGTH];
|
||||||
int n = _pStreamSocketImpl->receiveBytes(header, MAX_HEADER_LENGTH);
|
int n = _pStreamSocketImpl->receiveBytes(header, 2);
|
||||||
|
if (n == 1)
|
||||||
|
{
|
||||||
|
n += _pStreamSocketImpl->receiveBytes(header + 1, 1);
|
||||||
|
}
|
||||||
|
if (n == 2)
|
||||||
|
{
|
||||||
|
Poco::UInt8 lengthByte = static_cast<Poco::UInt8>(header[1]) & 0x7f;
|
||||||
|
if (lengthByte + 2 < MAX_HEADER_LENGTH)
|
||||||
|
{
|
||||||
|
n = _pStreamSocketImpl->receiveBytes(header + 2, lengthByte);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
n = _pStreamSocketImpl->receiveBytes(header + 2, MAX_HEADER_LENGTH - 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else throw WebSocketException("Incomplete frame received", WebSocket::WS_ERR_INCOMPLETE_FRAME);
|
||||||
|
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
|
n += 2;
|
||||||
Poco::MemoryInputStream istr(header, n);
|
Poco::MemoryInputStream istr(header, n);
|
||||||
Poco::BinaryReader reader(istr, Poco::BinaryReader::NETWORK_BYTE_ORDER);
|
Poco::BinaryReader reader(istr, Poco::BinaryReader::NETWORK_BYTE_ORDER);
|
||||||
Poco::UInt8 flags;
|
Poco::UInt8 flags;
|
||||||
|
@ -1 +1 @@
|
|||||||
14
|
15
|
||||||
|
Loading…
Reference in New Issue
Block a user