This commit is contained in:
Redkale
2018-09-27 09:54:42 +08:00
parent 0fa1c4a08f
commit 4a6404dfec

View File

@@ -894,9 +894,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
buffer.put(("HTTP/1.1 " + this.status + " " + httpCodes.get(this.status) + "\r\n").getBytes());
}
if (this.contentLength >= 0) buffer.put(("Content-Length: " + this.contentLength + "\r\n").getBytes());
buffer.put(serverNameBytes);
if (dateSupplier != null) buffer.put(dateSupplier.get());
if (!request.isWebSocket()) {
if (!this.request.isWebSocket()) {
if (this.contentType == this.jsonContentType) {
buffer.put(this.jsonContentTypeBytes);
} else if (this.contentType == null || this.contentType == this.plainContentType) {
@@ -904,6 +902,11 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
} else {
buffer.put(("Content-Type: " + (this.contentType == null ? this.plainContentType : this.contentType) + "\r\n").getBytes());
}
}
buffer.put(serverNameBytes);
if (dateSupplier != null) buffer.put(dateSupplier.get());
if (this.header.getValue("Connection") == null) {
buffer.put(this.request.isKeepAlive() ? connectAliveBytes : connectCloseBytes);
}