mirror of https://github.com/Icinga/icinga2.git
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");
|
||||
String msg = "<h1>Not found</h1>";
|
||||
response.WriteBody(msg.CStr(), msg.GetLength());
|
||||
response.Finish();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,9 @@ void HttpResponse::WriteBody(const char *data, size_t count)
|
|||
{
|
||||
ASSERT(m_State == HttpResponseHeaders || m_State == HttpResponseBody);
|
||||
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
if (m_Request.ProtocolVersion == HttpVersion10) {
|
||||
if (!m_Body)
|
||||
m_Body = new FIFO();
|
||||
|
@ -86,6 +89,9 @@ void HttpResponse::WriteBody(const char *data, size_t count)
|
|||
|
||||
void HttpResponse::Finish(void)
|
||||
{
|
||||
ASSERT(m_State != HttpResponseEnd);
|
||||
m_State = HttpResponseEnd;
|
||||
|
||||
if (m_Request.ProtocolVersion == HttpVersion10) {
|
||||
if (m_Body)
|
||||
AddHeader("Content-Length", Convert::ToString(m_Body->GetAvailableBytes()));
|
||||
|
|
|
@ -31,7 +31,8 @@ enum HttpResponseState
|
|||
{
|
||||
HttpResponseStart,
|
||||
HttpResponseHeaders,
|
||||
HttpResponseBody
|
||||
HttpResponseBody,
|
||||
HttpResponseEnd
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue