mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-31 01:24:19 +02:00
Fix: HttpHandler is calling HttpResponse::Finish twice for 404s
fixes #10024
This commit is contained in:
parent
f1a1dfb26e
commit
49fd5b582d
@ -104,7 +104,6 @@ void HttpHandler::ProcessRequest(const ApiUser::Ptr& user, HttpRequest& request,
|
|||||||
response.AddHeader("Content-Type", "text/html");
|
response.AddHeader("Content-Type", "text/html");
|
||||||
String msg = "<h1>Not found</h1>";
|
String msg = "<h1>Not found</h1>";
|
||||||
response.WriteBody(msg.CStr(), msg.GetLength());
|
response.WriteBody(msg.CStr(), msg.GetLength());
|
||||||
response.Finish();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,9 @@ void HttpResponse::WriteBody(const char *data, size_t count)
|
|||||||
{
|
{
|
||||||
ASSERT(m_State == HttpResponseHeaders || m_State == HttpResponseBody);
|
ASSERT(m_State == HttpResponseHeaders || m_State == HttpResponseBody);
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (m_Request.ProtocolVersion == HttpVersion10) {
|
if (m_Request.ProtocolVersion == HttpVersion10) {
|
||||||
if (!m_Body)
|
if (!m_Body)
|
||||||
m_Body = new FIFO();
|
m_Body = new FIFO();
|
||||||
@ -86,6 +89,9 @@ void HttpResponse::WriteBody(const char *data, size_t count)
|
|||||||
|
|
||||||
void HttpResponse::Finish(void)
|
void HttpResponse::Finish(void)
|
||||||
{
|
{
|
||||||
|
ASSERT(m_State != HttpResponseEnd);
|
||||||
|
m_State = HttpResponseEnd;
|
||||||
|
|
||||||
if (m_Request.ProtocolVersion == HttpVersion10) {
|
if (m_Request.ProtocolVersion == HttpVersion10) {
|
||||||
if (m_Body)
|
if (m_Body)
|
||||||
AddHeader("Content-Length", Convert::ToString(m_Body->GetAvailableBytes()));
|
AddHeader("Content-Length", Convert::ToString(m_Body->GetAvailableBytes()));
|
||||||
|
@ -31,7 +31,8 @@ enum HttpResponseState
|
|||||||
{
|
{
|
||||||
HttpResponseStart,
|
HttpResponseStart,
|
||||||
HttpResponseHeaders,
|
HttpResponseHeaders,
|
||||||
HttpResponseBody
|
HttpResponseBody,
|
||||||
|
HttpResponseEnd
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user