IXWebSocket/ixwebsocket/IXWebSocketHttpHeaders.h

46 lines
1.2 KiB
C
Raw Normal View History

/*
* IXWebSocketHttpHeaders.h
* Author: Benjamin Sergeant
* Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
*/
#pragma once
2019-02-15 05:11:42 +01:00
#include "IXCancellationRequest.h"
#include <string>
#include <map>
2019-02-15 05:11:42 +01:00
#include <memory>
#include <algorithm>
namespace ix
{
2019-02-15 05:11:42 +01:00
class Socket;
struct CaseInsensitiveLess
{
// 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 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
}
};
using WebSocketHttpHeaders = std::map<std::string, std::string, CaseInsensitiveLess>;
2019-02-15 05:11:42 +01:00
std::pair<bool, WebSocketHttpHeaders> parseHttpHeaders(
std::shared_ptr<Socket> socket,
const CancellationRequest& isCancellationRequested);
}