From 60b4425a47fe769089e01a9ff3bff0363045a3a2 Mon Sep 17 00:00:00 2001 From: redkale Date: Thu, 15 Aug 2024 23:06:14 +0800 Subject: [PATCH] chunked --- .../org/redkale/net/http/HttpRequest.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/redkale/net/http/HttpRequest.java b/src/main/java/org/redkale/net/http/HttpRequest.java index 7b7c12508..d94cdc108 100644 --- a/src/main/java/org/redkale/net/http/HttpRequest.java +++ b/src/main/java/org/redkale/net/http/HttpRequest.java @@ -118,6 +118,13 @@ public class HttpRequest extends Request { private boolean expect = false; // 是否Expect:100-continue + // @since 2.8.0 + protected boolean chunked = false; + + protected int chunkedLength = -1; + + protected byte[] chunkedHalfLenBytes; + protected boolean rpc; protected int readState = READ_STATE_ROUTE; @@ -153,8 +160,6 @@ public class HttpRequest extends Request { protected final HttpParameters params = HttpParameters.create(); - protected boolean chunked = false; - protected boolean boundary = false; protected int moduleid; @@ -295,6 +300,10 @@ public class HttpRequest extends Request { return expect; } + protected boolean isChunked() { + return chunked; + } + protected void setKeepAlive(boolean keepAlive) { this.keepAlive = keepAlive; } @@ -339,6 +348,8 @@ public class HttpRequest extends Request { this.keepAlive = httpLast.keepAlive; this.maybews = httpLast.maybews; this.expect = httpLast.expect; + this.chunked = httpLast.chunked; + this.chunkedLength = httpLast.chunkedLength; this.rpc = httpLast.rpc; this.traceid = httpLast.traceid; this.currentUserid = httpLast.currentUserid; @@ -1092,6 +1103,7 @@ public class HttpRequest extends Request { req.keepAlive = this.keepAlive; req.maybews = this.maybews; req.expect = this.expect; + req.chunked = this.chunked; req.rpc = this.rpc; req.traceid = this.traceid; req.currentUserid = this.currentUserid; @@ -1129,6 +1141,9 @@ public class HttpRequest extends Request { this.cookies = null; this.maybews = false; this.expect = false; + this.chunked = false; + this.chunkedLength = -1; + this.chunkedHalfLenBytes = null; this.rpc = false; this.readState = READ_STATE_ROUTE; this.currentUserid = CURRUSERID_NIL; @@ -1146,7 +1161,6 @@ public class HttpRequest extends Request { this.requestPath = null; this.queryBytes = null; this.boundary = false; - this.chunked = false; this.bodyParsed = false; this.moduleid = 0; this.actionid = 0; @@ -1176,7 +1190,7 @@ public class HttpRequest extends Request { } } - private void unzipEncoding() { + protected void unzipEncoding() { try { if ("gzip".contains(this.contentEncoding)) { ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -1746,6 +1760,7 @@ public class HttpRequest extends Request { + (this.protocol != null ? (", \r\n protocol: " + this.protocol) : "") + (this.getHost() != null ? (", \r\n host: " + this.host) : "") + (this.getContentLength() >= 0 ? (", \r\n contentLength: " + this.contentLength) : "") + + (this.contentEncoding != null ? (", \r\n contentEncoding: " + this.contentEncoding) : "") + (this.array.length() > 0 ? (", \r\n bodyLength: " + this.array.length()) : "") + (this.boundary || this.array.isEmpty() ? ""