2018-11-10 03:23:49 +01:00
|
|
|
/*
|
|
|
|
* IXWebSocketHttpHeaders.h
|
|
|
|
* Author: Benjamin Sergeant
|
|
|
|
* Copyright (c) 2018 Machine Zone, Inc. All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-01 06:54:03 +01:00
|
|
|
#include "IXCancellationRequest.h"
|
|
|
|
|
2018-11-10 03:23:49 +01:00
|
|
|
#include <string>
|
2019-03-01 06:54:03 +01:00
|
|
|
#include <map>
|
|
|
|
#include <memory>
|
|
|
|
#include <algorithm>
|
2018-11-10 03:23:49 +01:00
|
|
|
|
2019-02-21 03:59:07 +01:00
|
|
|
namespace ix
|
2018-11-10 03:23:49 +01:00
|
|
|
{
|
2019-03-01 06:54:03 +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>;
|
|
|
|
|
|
|
|
std::pair<bool, WebSocketHttpHeaders> parseHttpHeaders(
|
|
|
|
std::shared_ptr<Socket> socket,
|
|
|
|
const CancellationRequest& isCancellationRequested);
|
2018-11-10 03:23:49 +01:00
|
|
|
}
|