Add missing HTTP response headers

refs #9594
This commit is contained in:
Gunnar Beutner 2015-07-13 08:29:48 +02:00
parent 8dedd47b89
commit ceea8a24d3
2 changed files with 2 additions and 0 deletions

View File

@ -149,6 +149,7 @@ void HttpConnection::ProcessMessageAsync(HttpRequest& request)
if (!user) { if (!user) {
response.SetStatus(401, "Unauthorized"); response.SetStatus(401, "Unauthorized");
response.AddHeader("Content-Type", "text/html");
response.AddHeader("WWW-Authenticate", "Basic realm=\"Icinga 2\""); response.AddHeader("WWW-Authenticate", "Basic realm=\"Icinga 2\"");
String msg = "<h1>Unauthorized</h1>"; String msg = "<h1>Unauthorized</h1>";
response.WriteBody(msg.CStr(), msg.GetLength()); response.WriteBody(msg.CStr(), msg.GetLength());

View File

@ -88,6 +88,7 @@ void HttpHandler::ProcessRequest(const ApiUser::Ptr& user, HttpRequest& request,
if (!handler || (!exact_match && !handler->CanAlsoHandleUrl(request.RequestUrl))) { if (!handler || (!exact_match && !handler->CanAlsoHandleUrl(request.RequestUrl))) {
response.SetStatus(404, "Not found"); response.SetStatus(404, "Not found");
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(); response.Finish();