project builds / gross hack to disable compression code path / ws connect -x works but test fails
This commit is contained in:
		@@ -429,6 +429,16 @@ namespace ix
 | 
			
		||||
        return (binary) ? sendBinary(data, onProgressCallback) : sendText(data, onProgressCallback);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    WebSocketSendInfo WebSocket::sendBinary(const std::vector<uint8_t>& data,
 | 
			
		||||
                                            const OnProgressCallback& onProgressCallback)
 | 
			
		||||
    {
 | 
			
		||||
        if (!isConnected()) return WebSocketSendInfo(false);
 | 
			
		||||
        std::lock_guard<std::mutex> lock(_writeMutex);
 | 
			
		||||
        auto webSocketSendInfo = _ws.sendBinary(data, onProgressCallback);
 | 
			
		||||
        WebSocket::invokeTrafficTrackerCallback(webSocketSendInfo.wireSize, false);
 | 
			
		||||
        return webSocketSendInfo;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    WebSocketSendInfo WebSocket::sendBinary(const std::string& text,
 | 
			
		||||
                                            const OnProgressCallback& onProgressCallback)
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
@@ -74,8 +74,11 @@ namespace ix
 | 
			
		||||
        WebSocketSendInfo send(const std::string& data,
 | 
			
		||||
                               bool binary = false,
 | 
			
		||||
                               const OnProgressCallback& onProgressCallback = nullptr);
 | 
			
		||||
 | 
			
		||||
        WebSocketSendInfo sendBinary(const std::string& text,
 | 
			
		||||
                                     const OnProgressCallback& onProgressCallback = nullptr);
 | 
			
		||||
        WebSocketSendInfo sendBinary(const std::vector<uint8_t>& data,
 | 
			
		||||
                                     const OnProgressCallback& onProgressCallback = nullptr);
 | 
			
		||||
        WebSocketSendInfo sendText(const std::string& text,
 | 
			
		||||
                                   const OnProgressCallback& onProgressCallback = nullptr);
 | 
			
		||||
        WebSocketSendInfo ping(const std::string& text);
 | 
			
		||||
 
 | 
			
		||||
@@ -25,9 +25,8 @@ namespace ix
 | 
			
		||||
        bool compress(const std::vector<uint8_t>& in, std::string& out);
 | 
			
		||||
        bool compress(const std::vector<uint8_t>& in, std::vector<uint8_t>& out);
 | 
			
		||||
 | 
			
		||||
        template<typename T, typename S> bool compressData(const T& in, S& out);
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        template<typename T, typename S> bool compressData(const T& in, S& out);
 | 
			
		||||
        template<typename T> bool endsWithEmptyUnCompressedBlock(const T& value);
 | 
			
		||||
 | 
			
		||||
        int _flush;
 | 
			
		||||
 
 | 
			
		||||
@@ -751,11 +751,28 @@ namespace ix
 | 
			
		||||
        return static_cast<unsigned>(seconds);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template<class T>
 | 
			
		||||
    WebSocketSendInfo WebSocketTransport::sendData(wsheader_type::opcode_type type,
 | 
			
		||||
                                                   const T& message,
 | 
			
		||||
                                                   bool compress,
 | 
			
		||||
                                                   const OnProgressCallback& onProgressCallback)
 | 
			
		||||
                               const std::string& message,
 | 
			
		||||
                               bool compress,
 | 
			
		||||
                               const OnProgressCallback& onProgressCallback)
 | 
			
		||||
    {
 | 
			
		||||
        return sendRawData(type, message, compress, onProgressCallback);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    WebSocketSendInfo WebSocketTransport::sendData(wsheader_type::opcode_type type,
 | 
			
		||||
                               const std::vector<uint8_t>& message,
 | 
			
		||||
                               bool compress,
 | 
			
		||||
                               const OnProgressCallback& onProgressCallback)
 | 
			
		||||
    {
 | 
			
		||||
        return sendRawData(type, message, compress, onProgressCallback);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    template<class T>
 | 
			
		||||
    WebSocketSendInfo WebSocketTransport::sendRawData(wsheader_type::opcode_type type,
 | 
			
		||||
                                                      const T& message,
 | 
			
		||||
                                                      bool compress,
 | 
			
		||||
                                                      const OnProgressCallback& onProgressCallback)
 | 
			
		||||
    {
 | 
			
		||||
        if (_readyState != ReadyState::OPEN && _readyState != ReadyState::CLOSING)
 | 
			
		||||
        {
 | 
			
		||||
@@ -769,9 +786,11 @@ namespace ix
 | 
			
		||||
        auto message_begin = message.begin();
 | 
			
		||||
        auto message_end = message.end();
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
        if (compress)
 | 
			
		||||
        {
 | 
			
		||||
            if (!_perMessageDeflate->compress(message, _compressedMessage))
 | 
			
		||||
            T compressedMessage;
 | 
			
		||||
            if (!_perMessageDeflate->compress(message, compressedMessage))
 | 
			
		||||
            {
 | 
			
		||||
                bool success = false;
 | 
			
		||||
                compressionError = true;
 | 
			
		||||
@@ -780,11 +799,12 @@ namespace ix
 | 
			
		||||
                return WebSocketSendInfo(success, compressionError, payloadSize, wireSize);
 | 
			
		||||
            }
 | 
			
		||||
            compressionError = false;
 | 
			
		||||
            wireSize = _compressedMessage.size();
 | 
			
		||||
            wireSize = compressedMessage.size();
 | 
			
		||||
 | 
			
		||||
            message_begin = _compressedMessage.begin();
 | 
			
		||||
            message_end = _compressedMessage.end();
 | 
			
		||||
            message_begin = compressedMessage.begin();
 | 
			
		||||
            message_end = compressedMessage.end();
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        {
 | 
			
		||||
            std::lock_guard<std::mutex> lock(_txbufMutex);
 | 
			
		||||
@@ -810,8 +830,8 @@ namespace ix
 | 
			
		||||
            //
 | 
			
		||||
            auto steps = wireSize / kChunkSize;
 | 
			
		||||
 | 
			
		||||
            std::string::const_iterator begin = message_begin;
 | 
			
		||||
            std::string::const_iterator end = message_end;
 | 
			
		||||
            auto begin = message_begin;
 | 
			
		||||
            auto end = message_end;
 | 
			
		||||
 | 
			
		||||
            for (uint64_t i = 0; i < steps; ++i)
 | 
			
		||||
            {
 | 
			
		||||
@@ -964,6 +984,14 @@ namespace ix
 | 
			
		||||
        return info;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    WebSocketSendInfo WebSocketTransport::sendBinary(const std::vector<uint8_t>& message,
 | 
			
		||||
                                                     const OnProgressCallback& onProgressCallback)
 | 
			
		||||
 | 
			
		||||
    {
 | 
			
		||||
        return sendData(
 | 
			
		||||
            wsheader_type::BINARY_FRAME, message, _enablePerMessageDeflate, onProgressCallback);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    WebSocketSendInfo WebSocketTransport::sendBinary(const std::string& message,
 | 
			
		||||
                                                     const OnProgressCallback& onProgressCallback)
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -86,6 +86,9 @@ namespace ix
 | 
			
		||||
        WebSocketInitResult connectToSocket(std::unique_ptr<Socket> socket, int timeoutSecs);
 | 
			
		||||
 | 
			
		||||
        PollResult poll();
 | 
			
		||||
 | 
			
		||||
        WebSocketSendInfo sendBinary(const std::vector<uint8_t>& message,
 | 
			
		||||
                                     const OnProgressCallback& onProgressCallback);
 | 
			
		||||
        WebSocketSendInfo sendBinary(const std::string& message,
 | 
			
		||||
                                     const OnProgressCallback& onProgressCallback);
 | 
			
		||||
        WebSocketSendInfo sendText(const std::string& message,
 | 
			
		||||
@@ -190,7 +193,7 @@ namespace ix
 | 
			
		||||
        std::atomic<bool> _enablePerMessageDeflate;
 | 
			
		||||
 | 
			
		||||
        std::string _decompressedMessage;
 | 
			
		||||
        std::string _compressedMessage;
 | 
			
		||||
        std::vector<uint8_t> _compressedMessage;
 | 
			
		||||
 | 
			
		||||
        // Used to control TLS connection behavior
 | 
			
		||||
        SocketTLSOptions _socketTLSOptions;
 | 
			
		||||
@@ -239,12 +242,22 @@ namespace ix
 | 
			
		||||
        bool sendOnSocket();
 | 
			
		||||
        bool receiveFromSocket();
 | 
			
		||||
 | 
			
		||||
        template<class T>
 | 
			
		||||
        WebSocketSendInfo sendData(wsheader_type::opcode_type type,
 | 
			
		||||
                                   const T& message,
 | 
			
		||||
                                   const std::string& message,
 | 
			
		||||
                                   bool compress,
 | 
			
		||||
                                   const OnProgressCallback& onProgressCallback = nullptr);
 | 
			
		||||
 | 
			
		||||
        WebSocketSendInfo sendData(wsheader_type::opcode_type type,
 | 
			
		||||
                                   const std::vector<uint8_t>& message,
 | 
			
		||||
                                   bool compress,
 | 
			
		||||
                                   const OnProgressCallback& onProgressCallback = nullptr);
 | 
			
		||||
 | 
			
		||||
        template<class T>
 | 
			
		||||
        WebSocketSendInfo sendRawData(wsheader_type::opcode_type type,
 | 
			
		||||
                                      const T& message,
 | 
			
		||||
                                      bool compress,
 | 
			
		||||
                                      const OnProgressCallback& onProgressCallback = nullptr);
 | 
			
		||||
 | 
			
		||||
        template<class Iterator>
 | 
			
		||||
        bool sendFragment(wsheader_type::opcode_type type,
 | 
			
		||||
                          bool fin,
 | 
			
		||||
 
 | 
			
		||||
@@ -100,6 +100,7 @@ namespace
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        _webSocket.setUrl(url);
 | 
			
		||||
        _webSocket.disablePerMessageDeflate();
 | 
			
		||||
 | 
			
		||||
        std::stringstream ss;
 | 
			
		||||
        log(std::string("Connecting to url: ") + url);
 | 
			
		||||
@@ -188,7 +189,9 @@ namespace
 | 
			
		||||
 | 
			
		||||
    void WebSocketChat::sendMessage(const std::string& text)
 | 
			
		||||
    {
 | 
			
		||||
        _webSocket.sendBinary(encodeMessage(text));
 | 
			
		||||
        auto msg = encodeMessage(text);
 | 
			
		||||
        std::vector<uint8_t> data(text.begin(), text.end());
 | 
			
		||||
        _webSocket.sendBinary(data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool startServer(ix::WebSocketServer& server)
 | 
			
		||||
 
 | 
			
		||||
@@ -216,7 +216,8 @@ namespace ix
 | 
			
		||||
    {
 | 
			
		||||
        if (_binaryMode)
 | 
			
		||||
        {
 | 
			
		||||
            _webSocket.sendBinary(text);
 | 
			
		||||
            std::vector<uint8_t> data(text.begin(), text.end());
 | 
			
		||||
            _webSocket.sendBinary(data);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user