2019-02-25 08:48:22 -05:00
|
|
|
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
|
2015-07-21 10:10:13 -04:00
|
|
|
|
|
|
|
|
#ifndef HTTPUTILITY_H
|
|
|
|
|
#define HTTPUTILITY_H
|
|
|
|
|
|
2019-02-14 11:27:17 -05:00
|
|
|
#include "remote/url.hpp"
|
2015-07-21 10:10:13 -04:00
|
|
|
#include "base/dictionary.hpp"
|
2025-07-23 03:37:05 -04:00
|
|
|
#include "remote/httpmessage.hpp"
|
2019-05-23 09:25:08 -04:00
|
|
|
#include <string>
|
2015-07-21 10:10:13 -04:00
|
|
|
|
|
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Helper functions.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup remote
|
|
|
|
|
*/
|
2017-12-31 01:22:16 -05:00
|
|
|
class HttpUtility
|
2015-07-21 10:10:13 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public:
|
2019-02-14 11:27:17 -05:00
|
|
|
static Dictionary::Ptr FetchRequestParameters(const Url::Ptr& url, const std::string& body);
|
2015-07-30 11:50:17 -04:00
|
|
|
static Value GetLastParameter(const Dictionary::Ptr& params, const String& key);
|
2019-05-23 09:25:08 -04:00
|
|
|
|
2026-01-22 06:41:21 -05:00
|
|
|
static void SendJsonBody(HttpApiResponse& response, const Dictionary::Ptr& params, const Value& val);
|
|
|
|
|
static void SendJsonError(HttpApiResponse& response, const Dictionary::Ptr& params, const int code,
|
2025-07-23 03:37:05 -04:00
|
|
|
const String& info = {}, const String& diagnosticInformation = {});
|
2025-11-28 03:52:17 -05:00
|
|
|
|
|
|
|
|
static bool IsValidHeaderName(std::string_view name);
|
|
|
|
|
static bool IsValidHeaderValue(std::string_view value);
|
2015-07-21 10:10:13 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* HTTPUTILITY_H */
|