diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java index 2d0da1968c9..8b557e3147b 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpFields.java @@ -217,10 +217,10 @@ public class HttpFields implements Iterable /** * Get multi headers * - * @return Enumeration of the values, or null if no such header. + * @return List the values * @param name the case-insensitive field name */ - public Collection getValuesCollection(String name) + public List getValuesList(String name) { final List list = new ArrayList<>(); for (HttpField f : _fields) diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java index bd698f7b133..1ec062f5812 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java @@ -585,43 +585,45 @@ public class Response implements HttpServletResponse { setHeader(HttpHeader.CACHE_CONTROL, "must-revalidate,no-cache,no-store"); setContentType(MimeTypes.Type.TEXT_HTML_8859_1.toString()); - ByteArrayISO8859Writer writer= new ByteArrayISO8859Writer(2048); - if (message != null) + try (ByteArrayISO8859Writer writer= new ByteArrayISO8859Writer(2048);) { - message= StringUtil.replace(message, "&", "&"); - message= StringUtil.replace(message, "<", "<"); - message= StringUtil.replace(message, ">", ">"); - } - String uri= request.getRequestURI(); - if (uri!=null) - { - uri= StringUtil.replace(uri, "&", "&"); - uri= StringUtil.replace(uri, "<", "<"); - uri= StringUtil.replace(uri, ">", ">"); - } + if (message != null) + { + message= StringUtil.replace(message, "&", "&"); + message= StringUtil.replace(message, "<", "<"); + message= StringUtil.replace(message, ">", ">"); + } + String uri= request.getRequestURI(); + if (uri!=null) + { + uri= StringUtil.replace(uri, "&", "&"); + uri= StringUtil.replace(uri, "<", "<"); + uri= StringUtil.replace(uri, ">", ">"); + } - writer.write("\n\n\n"); - writer.write("Error "); - writer.write(Integer.toString(code)); - writer.write(' '); - if (message==null) - writer.write(message); - writer.write("\n\n\n

HTTP ERROR: "); - writer.write(Integer.toString(code)); - writer.write("

\n

Problem accessing "); - writer.write(uri); - writer.write(". Reason:\n

    ");
-                writer.write(message);
-                writer.write("
"); - writer.write("

\n
Powered by Jetty://"); - writer.write("\n\n\n"); + writer.write("\n\n\n"); + writer.write("Error "); + writer.write(Integer.toString(code)); + writer.write(' '); + if (message==null) + writer.write(message); + writer.write("\n\n\n

HTTP ERROR: "); + writer.write(Integer.toString(code)); + writer.write("

\n

Problem accessing "); + writer.write(uri); + writer.write(". Reason:\n

    ");
+                    writer.write(message);
+                    writer.write("
"); + writer.write("

\n
Powered by Jetty://"); + writer.write("\n\n\n"); - writer.flush(); - setContentLength(writer.size()); - try (ServletOutputStream outputStream = getOutputStream()) - { - writer.writeTo(outputStream); - writer.destroy(); + writer.flush(); + setContentLength(writer.size()); + try (ServletOutputStream outputStream = getOutputStream()) + { + writer.writeTo(outputStream); + writer.destroy(); + } } } } @@ -816,7 +818,7 @@ public class Response implements HttpServletResponse public Collection getHeaders(String name) { final HttpFields fields = _fields; - Collection i = fields.getValuesCollection(name); + Collection i = fields.getValuesList(name); if (i == null) return Collections.emptyList(); return i;