From 3f608b91e908763c3716e838a5835d79c6047120 Mon Sep 17 00:00:00 2001 From: Redkale <22250530@qq.com> Date: Tue, 17 Apr 2018 08:45:31 +0800 Subject: [PATCH] --- src/org/redkale/net/http/HttpResponse.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/org/redkale/net/http/HttpResponse.java b/src/org/redkale/net/http/HttpResponse.java index 313eb3ec6..b79b65163 100644 --- a/src/org/redkale/net/http/HttpResponse.java +++ b/src/org/redkale/net/http/HttpResponse.java @@ -44,6 +44,8 @@ public class HttpResponse extends Response { protected static final byte[] serverNameBytes = ("Server: " + System.getProperty("http.response.header.server", "redkale" + "/" + Redkale.getDotedVersion()) + "\r\n").getBytes(); + protected static final byte[] connectCloseBytes = "Connection: close\r\n".getBytes(); + private static final Set options = new HashSet<>(); private static final Map httpCodes = new HashMap<>(); @@ -848,16 +850,13 @@ public class HttpResponse extends Response { ByteBuffer buffer = this.pollWriteReadBuffer(); buffer.put(("HTTP/1.1 " + this.status + " " + (this.status == 200 ? "OK" : httpCodes.get(this.status)) + "\r\n").getBytes()); - buffer.put(("Content-Type: " + (this.contentType == null ? this.plainContentType : this.contentType) + "\r\n").getBytes()); - if (this.contentLength >= 0) { buffer.put(("Content-Length: " + this.contentLength + "\r\n").getBytes()); } - if (!this.request.isKeepAlive()) { - buffer.put("Connection: close\r\n".getBytes()); - } - buffer.put(("Date: " + RFC_1123_DATE_TIME.format(java.time.ZonedDateTime.now(ZONE_GMT)) + "\r\n").getBytes()); + buffer.put(("Content-Type: " + (this.contentType == null ? this.plainContentType : this.contentType) + "\r\n").getBytes()); buffer.put(serverNameBytes); + buffer.put(("Date: " + RFC_1123_DATE_TIME.format(java.time.ZonedDateTime.now(ZONE_GMT)) + "\r\n").getBytes()); + if (!this.request.isKeepAlive()) buffer.put(connectCloseBytes); if (this.defaultAddHeaders != null) { for (String[] headers : this.defaultAddHeaders) {