From c5b92defec03f989eb22da2ff769c2314dd7e618 Mon Sep 17 00:00:00 2001 From: Jean Flach Date: Wed, 21 Feb 2018 13:22:17 +0100 Subject: [PATCH] Minor codestyle and doc changes --- doc/12-icinga2-api.md | 10 ++++------ lib/base/tlsstream.cpp | 1 - lib/remote/httprequest.cpp | 2 +- lib/remote/httprequest.hpp | 2 +- lib/remote/httpserverconnection.cpp | 9 +++++---- lib/remote/httpserverconnection.hpp | 1 - 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/doc/12-icinga2-api.md b/doc/12-icinga2-api.md index acebac6e1..b2e61765b 100644 --- a/doc/12-icinga2-api.md +++ b/doc/12-icinga2-api.md @@ -201,13 +201,12 @@ The [regex function](18-library-reference.md#global-functions-regex) is availabl More information about filters can be found in the [filters](12-icinga2-api.md#icinga2-api-filters) chapter. -Note that the permissions a API user has also specify the max body size of their requests. -A API user with `*` permissions is allowed to send 512 MB. - +Permissions are tied to a maximum HTTP request size to prevent abuse, responses sent by Icinga are not limited. +An API user with all permissions ("\*") may send up to 512 MB regardless of the endpoint. Available permissions for specific URL endpoints: - Permissions | URL Endpoint | Supports Filters | Max Body Size in MB + Permissions | URL Endpoint | Supports filters | Max body size in MB ------------------------------|---------------|-------------------|--------------------- actions/<action> | /v1/actions | Yes | 1 config/query | /v1/config | No | 1 @@ -227,8 +226,7 @@ The required actions or types can be replaced by using a wildcard match ("\*"). ### Parameters -Depending on the request method there are two ways of -passing parameters to the request: +Depending on the request method there are two ways of passing parameters to the request: * JSON object as request body (all request methods other than `GET`) * Query string as URL parameter (all request methods) diff --git a/lib/base/tlsstream.cpp b/lib/base/tlsstream.cpp index 953b2b8f0..1fda60382 100644 --- a/lib/base/tlsstream.cpp +++ b/lib/base/tlsstream.cpp @@ -29,7 +29,6 @@ #endif /* _WIN32 */ #define TLS_TIMEOUT_SECONDS 10 -#define TLS_TIMEOUT_STEP_SECONDS 1 using namespace icinga; diff --git a/lib/remote/httprequest.cpp b/lib/remote/httprequest.cpp index a55e12638..9e8f36c27 100644 --- a/lib/remote/httprequest.cpp +++ b/lib/remote/httprequest.cpp @@ -38,7 +38,7 @@ HttpRequest::HttpRequest(const Stream::Ptr& stream) m_State(HttpRequestStart) { } -bool HttpRequest::ParseHeader(StreamReadContext& src, bool may_wait) +bool HttpRequest::ParseHeaders(StreamReadContext& src, bool may_wait) { if (!m_Stream) return false; diff --git a/lib/remote/httprequest.hpp b/lib/remote/httprequest.hpp index af7ebfbaa..a17732f4a 100644 --- a/lib/remote/httprequest.hpp +++ b/lib/remote/httprequest.hpp @@ -64,7 +64,7 @@ public: HttpRequest(const Stream::Ptr& stream); - bool ParseHeader(StreamReadContext& src, bool may_wait); + bool ParseHeaders(StreamReadContext& src, bool may_wait); bool ParseBody(StreamReadContext& src, bool may_wait); size_t ReadBody(char *data, size_t count); diff --git a/lib/remote/httpserverconnection.cpp b/lib/remote/httpserverconnection.cpp index ae284df34..1c236ed5a 100644 --- a/lib/remote/httpserverconnection.cpp +++ b/lib/remote/httpserverconnection.cpp @@ -24,12 +24,13 @@ #include "remote/apifunction.hpp" #include "remote/jsonrpc.hpp" #include "base/base64.hpp" +#include "base/convert.hpp" #include "base/configtype.hpp" +#include "base/exception.hpp" +#include "base/logger.hpp" #include "base/objectlock.hpp" +#include "base/timer.hpp" #include "base/utility.hpp" -#include "base/logger.hpp" -#include "base/exception.hpp" -#include "base/convert.hpp" #include using namespace icinga; @@ -101,7 +102,7 @@ bool HttpServerConnection::ProcessMessage(void) if (!m_CurrentRequest.CompleteHeaders) { try { - res = m_CurrentRequest.ParseHeader(m_Context, false); + res = m_CurrentRequest.ParseHeaders(m_Context, false); } catch (const std::invalid_argument& ex) { response.SetStatus(400, "Bad Request"); String msg = String("

Bad Request

") + ex.what() + "

"; diff --git a/lib/remote/httpserverconnection.hpp b/lib/remote/httpserverconnection.hpp index 22b036c2f..3d9b04e2c 100644 --- a/lib/remote/httpserverconnection.hpp +++ b/lib/remote/httpserverconnection.hpp @@ -24,7 +24,6 @@ #include "remote/httpresponse.hpp" #include "remote/apiuser.hpp" #include "base/tlsstream.hpp" -#include "base/timer.hpp" #include "base/workqueue.hpp" namespace icinga -- 2.40.0