nanohttpd: refactor: simplify keep-alive check

This commit is contained in:
Haowei Wen 2020-08-26 19:56:03 +08:00
parent f84afc976e
commit 514f2829e2
No known key found for this signature in database
GPG key ID: 5BC167F73EA558E4

View file

@ -205,9 +205,6 @@ class HTTPSession implements IHTTPSession {
try {
parseHeader(new BufferedReader(new InputStreamReader(readHeader(), ISO_8859_1)));
String connection = this.headers.get("connection");
boolean keepAlive = "HTTP/1.1".equals(this.protocolVersion) && (connection == null || !connection.matches("(?i).*close.*"));
String transferEncoding = this.headers.get("transfer-encoding");
String contentLengthStr = this.headers.get("content-length");
if (transferEncoding != null && contentLengthStr == null) {
@ -257,6 +254,8 @@ class HTTPSession implements IHTTPSession {
;
}
boolean keepAlive = "HTTP/1.1".equals(this.protocolVersion) && !"close".equals(this.headers.get("connection"));
if (r == null) {
throw new ResponseException(Status.INTERNAL_ERROR, "SERVER INTERNAL ERROR: Serve() returned a null response.");
} else {