fix windows build (#29)
* fix windows build * fix for Unix * Fix build if TLS is OFF * add OpenSSL req to ws * Fix build on Mac * fix tests for windows
This commit is contained in:
committed by
Benjamin Sergeant
parent
d4b0839328
commit
401fc39879
@ -21,6 +21,10 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
namespace ix
|
||||
{
|
||||
const int Socket::kDefaultPollNoTimeout = -1; // No poll timeout by default
|
||||
|
@ -6,12 +6,20 @@
|
||||
|
||||
#include "IXSocketFactory.h"
|
||||
|
||||
#if defined(__APPLE__) or defined(__linux__)
|
||||
#ifdef IXWEBSOCKET_USE_TLS
|
||||
|
||||
# ifdef __APPLE__
|
||||
# include <ixwebsocket/IXSocketAppleSSL.h>
|
||||
# elif defined(_WIN32)
|
||||
# include <ixwebsocket/IXSocketSChannel.h>
|
||||
# else
|
||||
# include <ixwebsocket/IXSocketOpenSSL.h>
|
||||
# endif
|
||||
|
||||
#else
|
||||
|
||||
#include <ixwebsocket/IXSocket.h>
|
||||
|
||||
#endif
|
||||
|
||||
namespace ix
|
||||
@ -31,6 +39,8 @@ namespace ix
|
||||
#ifdef IXWEBSOCKET_USE_TLS
|
||||
# ifdef __APPLE__
|
||||
socket = std::make_shared<SocketAppleSSL>();
|
||||
# elif defined(_WIN32)
|
||||
socket = std::make_shared<SocketSChannel>();
|
||||
# else
|
||||
socket = std::make_shared<SocketOpenSSL>();
|
||||
# endif
|
||||
|
@ -8,6 +8,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
|
@ -18,7 +18,7 @@
|
||||
# include <ws2def.h>
|
||||
# include <WS2tcpip.h>
|
||||
# include <schannel.h>
|
||||
# include <sslsock.h>
|
||||
//# include <sslsock.h>
|
||||
# include <io.h>
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
@ -75,7 +75,7 @@ namespace ix
|
||||
int port,
|
||||
std::string& errMsg)
|
||||
{
|
||||
return Socket::connect(host, port, errMsg);
|
||||
return Socket::connect(host, port, errMsg, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@ -89,17 +89,17 @@ namespace ix
|
||||
Socket::close();
|
||||
}
|
||||
|
||||
int SocketSChannel::send(char* buf, size_t nbyte)
|
||||
ssize_t SocketSChannel::send(char* buf, size_t nbyte)
|
||||
{
|
||||
return Socket::send(buf, nbyte);
|
||||
}
|
||||
|
||||
int SocketSChannel::send(const std::string& buffer)
|
||||
ssize_t SocketSChannel::send(const std::string& buffer)
|
||||
{
|
||||
return Socket::send(buffer);
|
||||
}
|
||||
|
||||
int SocketSChannel::recv(void* buf, size_t nbyte)
|
||||
ssize_t SocketSChannel::recv(void* buf, size_t nbyte)
|
||||
{
|
||||
return Socket::recv(buf, nbyte);
|
||||
}
|
||||
|
@ -24,9 +24,9 @@ namespace ix
|
||||
// The important override
|
||||
virtual void secureSocket() final;
|
||||
|
||||
virtual int send(char* buffer, size_t length) final;
|
||||
virtual int send(const std::string& buffer) final;
|
||||
virtual int recv(void* buffer, size_t length) final;
|
||||
virtual ssize_t send(char* buffer, size_t length) final;
|
||||
virtual ssize_t send(const std::string& buffer) final;
|
||||
virtual ssize_t recv(void* buffer, size_t length) final;
|
||||
|
||||
private:
|
||||
};
|
||||
|
@ -6,12 +6,28 @@
|
||||
|
||||
#include "IXWebSocketHttpHeaders.h"
|
||||
#include "IXSocket.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <algorithm>
|
||||
#include <locale>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
bool CaseInsensitiveLess::NocaseCompare::operator()(const unsigned char & c1, const unsigned char & c2) const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
return std::tolower(c1, std::locale()) < std::tolower(c2, std::locale());
|
||||
#else
|
||||
return std::tolower(c1) < std::tolower(c2);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CaseInsensitiveLess::operator()(const std::string & s1, const std::string & s2) const
|
||||
{
|
||||
return std::lexicographical_compare
|
||||
(s1.begin(), s1.end(), // source range
|
||||
s2.begin(), s2.end(), // dest range
|
||||
NocaseCompare()); // comparison
|
||||
}
|
||||
|
||||
std::pair<bool, WebSocketHttpHeaders> parseHttpHeaders(
|
||||
std::shared_ptr<Socket> socket,
|
||||
const CancellationRequest& isCancellationRequested)
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
|
||||
namespace ix
|
||||
{
|
||||
@ -22,19 +21,10 @@ namespace ix
|
||||
// Case Insensitive compare_less binary function
|
||||
struct NocaseCompare
|
||||
{
|
||||
bool operator() (const unsigned char& c1, const unsigned char& c2) const
|
||||
{
|
||||
return std::tolower(c1) < std::tolower(c2);
|
||||
}
|
||||
bool operator() (const unsigned char& c1, const unsigned char& c2) const;
|
||||
};
|
||||
|
||||
bool operator() (const std::string & s1, const std::string & s2) const
|
||||
{
|
||||
return std::lexicographical_compare
|
||||
(s1.begin(), s1.end(), // source range
|
||||
s2.begin(), s2.end(), // dest range
|
||||
NocaseCompare()); // comparison
|
||||
}
|
||||
bool operator() (const std::string & s1, const std::string & s2) const;
|
||||
};
|
||||
|
||||
using WebSocketHttpHeaders = std::map<std::string, std::string, CaseInsensitiveLess>;
|
||||
|
Reference in New Issue
Block a user