You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2020/04/06 14:50:52 UTC
[tomcat] branch master updated: Use a constant for the data size
This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new 80576b4 Use a constant for the data size
80576b4 is described below
commit 80576b44860c3db119a8c3b8caa48852f74e4d02
Author: remm <re...@apache.org>
AuthorDate: Mon Apr 6 16:50:36 2020 +0200
Use a constant for the data size
---
test/org/apache/tomcat/util/net/TestSsl.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/test/org/apache/tomcat/util/net/TestSsl.java b/test/org/apache/tomcat/util/net/TestSsl.java
index 715cefa..a560b55 100644
--- a/test/org/apache/tomcat/util/net/TestSsl.java
+++ b/test/org/apache/tomcat/util/net/TestSsl.java
@@ -79,6 +79,8 @@ public class TestSsl extends TomcatBaseTest {
TesterSupport.getLastClientAuthRequestedIssuerCount() == 0);
}
+ private static final int POST_DATA_SIZE = 16 * 1024 * 1024;
+
@Test
public void testPost() throws Exception {
SocketFactory socketFactory = TesterSupport.configureClientSsl();
@@ -103,7 +105,7 @@ public class TestSsl extends TomcatBaseTest {
OutputStream os = socket.getOutputStream();
- byte[] bytes = new byte[16 * 1024 * 1024]; // 16MB
+ byte[] bytes = new byte[POST_DATA_SIZE]; // 16MB
Arrays.fill(bytes, (byte) 1);
os.write("POST /post HTTP/1.1\r\n".getBytes());
@@ -284,7 +286,7 @@ public class TestSsl extends TomcatBaseTest {
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream(POST_DATA_SIZE);
byte[] in = new byte[1500];
InputStream input = req.getInputStream();
while (true) {
@@ -296,6 +298,7 @@ public class TestSsl extends TomcatBaseTest {
}
}
byte[] out = baos.toByteArray();
+ // Set the content-length to avoid having to parse chunked
resp.setContentLength(out.length);
resp.getOutputStream().write(out);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org