Issue #10474 support application/json for ErrorHandler (#10504)

This commit is contained in:
Jan Bartel 2023-09-15 03:12:48 +02:00 committed by GitHub
parent 049cf3a334
commit 26fdbe3280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -223,7 +223,7 @@ public class ErrorHandler implements Request.Handler
switch (type)
{
case TEXT_HTML -> writeErrorHtml(request, writer, charset, code, message, cause, showStacks);
case TEXT_JSON -> writeErrorJson(request, writer, code, message, cause, showStacks);
case TEXT_JSON, APPLICATION_JSON -> writeErrorJson(request, writer, code, message, cause, showStacks);
case TEXT_PLAIN -> writeErrorPlain(request, writer, code, message, cause, showStacks);
default -> throw new IllegalStateException();
}

View File

@ -617,10 +617,17 @@ public class ErrorHandlerTest
"\r\n");
HttpTester.Response response = HttpTester.parseResponse(rawResponse);
assertThat("Response status code", response.getStatus(), is(444));
assertContent(response);
rawResponse = connector.getResponse(
"GET /badmessage/444 HTTP/1.1\r\n" +
"Host: Localhost\r\n" +
"Accept: application/json\r\n" +
"\r\n");
response = HttpTester.parseResponse(rawResponse);
assertThat("Response status code", response.getStatus(), is(444));
}
@ParameterizedTest