MCPcopy Create free account
hub / github.com/Icinga/icinga2 / EnsureAcceptHeader

Function EnsureAcceptHeader

lib/remote/httpserverconnection.cpp:277–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277static inline
278bool EnsureAcceptHeader(
279 const HttpApiRequest& request,
280 HttpApiResponse& response,
281 boost::asio::yield_context& yc
282)
283{
284 namespace http = boost::beast::http;
285
286 if (request.method() != http::verb::get && request[http::field::accept] != "application/json") {
287 response.result(http::status::bad_request);
288 response.set(http::field::content_type, "text/html");
289 response.body() << "<h1>Accept header is missing or not set to 'application/json'.</h1>";
290 response.set(http::field::connection, "close");
291
292 response.Flush(yc);
293
294 return false;
295 }
296
297 return true;
298}
299
300static inline
301bool EnsureAuthenticatedUser(

Callers 1

ProcessMessagesMethod · 0.85

Calls 1

FlushMethod · 0.45

Tested by

no test coverage detected