Improve logging of mismatched Hosts

This commit is contained in:
Evgeniy Khramtsov 2017-10-05 11:33:29 +03:00
parent 94de13981b
commit 6f922275eb
1 changed files with 4 additions and 2 deletions

View File

@ -66,6 +66,8 @@
{-1, 403, [], <<"Forbidden">>}).
-define(HTTP_ERR_REQUEST_AUTH,
{-1, 401, ?REQUEST_AUTH_HEADERS, <<"Unauthorized">>}).
-define(HTTP_ERR_HOST_UNKNOWN,
{-1, 410, [], <<"Host unknown">>}).
-define(DEFAULT_CONTENT_TYPE,
<<"application/octet-stream">>).
@ -313,8 +315,8 @@ process(LocalPath, #request{host = Host, auth = Auth, headers = RHeaders} = Requ
?DEBUG("Received an HTTP request with Host: ~s, "
"but couldn't find the related "
"ejabberd virtual host", [Host]),
{FileSize1, Code1, Headers1, Contents1} = ?HTTP_ERR_FILE_NOT_FOUND,
add_to_log(FileSize1, Code1, Request),
{FileSize1, Code1, Headers1, Contents1} = ?HTTP_ERR_HOST_UNKNOWN,
add_to_log(FileSize1, Code1, Request#request{host = ?MYNAME}),
{Code1, Headers1, Contents1}
end.