Merge pull request #6357 from Icinga/fix/http-header-size

Increase header size to 8KB for HTTP requests
This commit is contained in:
Jean Flach 2018-06-07 11:00:09 +02:00 committed by GitHub
commit 197477b6d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 deletions

View File

@ -83,6 +83,8 @@ All requests apart from `GET` require that the following `Accept` header is set:
Each URL is prefixed with the API version (currently "/v1"). Each URL is prefixed with the API version (currently "/v1").
HTTP header size is limited to 8KB.
### Responses <a id="icinga2-api-responses"></a> ### Responses <a id="icinga2-api-responses"></a>
Successful requests will send back a response body containing a `results` Successful requests will send back a response body containing a `results`

View File

@ -46,14 +46,20 @@ bool HttpRequest::ParseHeaders(StreamReadContext& src, bool may_wait)
StreamReadStatus srs = m_Stream->ReadLine(&line, src, may_wait); StreamReadStatus srs = m_Stream->ReadLine(&line, src, may_wait);
if (srs != StatusNewItem) { if (srs != StatusNewItem) {
if (src.Size > 512) if (src.Size > 8 * 1024)
BOOST_THROW_EXCEPTION(std::invalid_argument("Line length for HTTP header exceeded")); BOOST_THROW_EXCEPTION(std::invalid_argument("Line length for HTTP header exceeded"));
return false; return false;
} }
if (line.GetLength() > 512) if (line.GetLength() > 8 * 1024) {
#ifdef I2_DEBUG /* I2_DEBUG */
Log(LogDebug, "HttpRequest")
<< "Header size: " << line.GetLength() << " content: '" << line << "'.";
#endif /* I2_DEBUG */
BOOST_THROW_EXCEPTION(std::invalid_argument("Line length for HTTP header exceeded")); BOOST_THROW_EXCEPTION(std::invalid_argument("Line length for HTTP header exceeded"));
}
if (m_State == HttpRequestStart) { if (m_State == HttpRequestStart) {
/* ignore trailing new-lines */ /* ignore trailing new-lines */