icinga2/lib/remote/httpserverconnection.hpp

64 lines
1.3 KiB
C++
Raw Normal View History

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
#ifndef HTTPSERVERCONNECTION_H
#define HTTPSERVERCONNECTION_H
2015-06-22 11:11:21 +02:00
#include "remote/httprequest.hpp"
#include "remote/httpresponse.hpp"
2015-06-22 11:11:21 +02:00
#include "remote/apiuser.hpp"
#include "base/tlsstream.hpp"
#include "base/workqueue.hpp"
#include <boost/thread/recursive_mutex.hpp>
namespace icinga
{
/**
* An API client connection.
*
* @ingroup remote
*/
2018-01-04 06:11:04 +01:00
class HttpServerConnection final : public Object
{
public:
DECLARE_PTR_TYPEDEFS(HttpServerConnection);
HttpServerConnection(const String& identity, bool authenticated, const TlsStream::Ptr& stream);
void Start();
ApiUser::Ptr GetApiUser() const;
bool IsAuthenticated() const;
TlsStream::Ptr GetStream() const;
void Disconnect();
private:
2015-06-22 11:11:21 +02:00
ApiUser::Ptr m_ApiUser;
ApiUser::Ptr m_AuthenticatedUser;
TlsStream::Ptr m_Stream;
double m_Seen;
2015-06-22 11:11:21 +02:00
HttpRequest m_CurrentRequest;
boost::recursive_mutex m_DataHandlerMutex;
2015-06-22 11:11:21 +02:00
WorkQueue m_RequestQueue;
int m_PendingRequests;
String m_PeerAddress;
StreamReadContext m_Context;
bool ProcessMessage();
void DataAvailableHandler();
static void StaticInitialize();
static void TimeoutTimerHandler();
void CheckLiveness();
2015-06-22 11:11:21 +02:00
bool ManageHeaders(HttpResponse& response);
void ProcessMessageAsync(HttpRequest& request, HttpResponse& response, const ApiUser::Ptr&);
};
}
#endif /* HTTPSERVERCONNECTION_H */