From 0fa1c4a08f0dc938e16fd15d0ac9e5dbe7974ac6 Mon Sep 17 00:00:00 2001 From: Redkale <8730487+redkale@users.noreply.github.com> Date: Thu, 27 Sep 2018 09:51:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DWebSocket=E4=B8=ADConnection?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/org/redkale/net/http/HttpResponse.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/org/redkale/net/http/HttpResponse.java b/src/org/redkale/net/http/HttpResponse.java index 9d5b3acc6..a16bf01bb 100644 --- a/src/org/redkale/net/http/HttpResponse.java +++ b/src/org/redkale/net/http/HttpResponse.java @@ -894,16 +894,18 @@ public class HttpResponse extends Response { 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()); - if (this.contentType == this.jsonContentType) { - buffer.put(this.jsonContentTypeBytes); - } else if (this.contentType == null || this.contentType == this.plainContentType) { - buffer.put(this.plainContentTypeBytes); - } 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()); - buffer.put(this.request.isKeepAlive() ? connectAliveBytes : connectCloseBytes); + if (!request.isWebSocket()) { + if (this.contentType == this.jsonContentType) { + buffer.put(this.jsonContentTypeBytes); + } else if (this.contentType == null || this.contentType == this.plainContentType) { + buffer.put(this.plainContentTypeBytes); + } else { + buffer.put(("Content-Type: " + (this.contentType == null ? this.plainContentType : this.contentType) + "\r\n").getBytes()); + } + buffer.put(this.request.isKeepAlive() ? connectAliveBytes : connectCloseBytes); + } if (this.defaultAddHeaders != null) { for (String[] headers : this.defaultAddHeaders) {