2026-01-27 09:06:40 -05:00
|
|
|
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
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"
|
2025-09-11 07:12:23 -04:00
|
|
|
#include <boost/asio/spawn.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
|
|
|
|
2025-09-11 07:12:23 -04:00
|
|
|
static void SendJsonBody(HttpApiResponse& response, const Dictionary::Ptr& params, const Value& val, boost::asio::yield_context& yc);
|
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 */
|