keep-alive必须要有content-length

This commit is contained in:
redkale
2024-08-15 17:52:45 +08:00
parent dd0debd51e
commit 6edf8b58fc

View File

@@ -383,6 +383,11 @@ public class HttpRequest extends Request<HttpContext> {
}
return lr > 0 ? lr : 0;
}
// keep-alive=true: Content-Length和chunk必然是二选一。
// keep-alive=false: Content-Length可有可无.
if (keepAlive && this.contentLength < 0) {
return -1;
}
if (buffer.hasRemaining() && (this.boundary || !this.keepAlive)) {
bytes.put(buffer, buffer.remaining()); // 文件上传、HTTP1.0或Connection:close
}