diff --git a/src/org/redkale/net/http/HttpResponse.java b/src/org/redkale/net/http/HttpResponse.java index 6cc265a53..f1da63de3 100644 --- a/src/org/redkale/net/http/HttpResponse.java +++ b/src/org/redkale/net/http/HttpResponse.java @@ -48,6 +48,8 @@ public class HttpResponse extends Response { protected static final byte[] connectCloseBytes = "Connection: close\r\n".getBytes(); + protected static final byte[] connectAliveBytes = "Connection: keep-alive\r\n".getBytes(); + private static final Set options = new HashSet<>(); private static final Map httpCodes = new HashMap<>(); @@ -874,7 +876,7 @@ public class HttpResponse extends Response { } buffer.put(serverNameBytes); if (autoDate) buffer.put(("Date: " + RFC_1123_DATE_TIME.format(java.time.ZonedDateTime.now(ZONE_GMT)) + "\r\n").getBytes()); - if (!this.request.isKeepAlive()) buffer.put(connectCloseBytes); + buffer.put(this.request.isKeepAlive() ? connectAliveBytes : connectCloseBytes); if (this.defaultAddHeaders != null) { for (String[] headers : this.defaultAddHeaders) {