ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/jakarta/servlet/TestServletRequestParametersMultipartEncoded.java

Path
ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/jakarta/servlet/TestServletRequestParametersMultipartEncoded.java
Status
scanned
Type
file
Name
TestServletRequestParametersMultipartEncoded.java
Extension
.java
Programming language
Java
Mime type
text/plain
File type
ASCII text, with CRLF line terminators
Tag

      
    
Rootfs path

      
    
Size
5316 (5.2 KB)
MD5
d1a687258cba3fe765a28774d7d2b456
SHA1
c6de16ded6801c09fe56586a12893b096800fd6c
SHA256
62a50da7a5d61c45ae28504ca7294418ef8b6db42d4979b4632070fe97988946
SHA512

      
    
SHA1_git
16ff3711a6e7c2aeb4245fcbf295a622ced06363
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestServletRequestParametersMultipartEncoded.java | 5.2 KB |

/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package jakarta.servlet; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collection; import java.util.List; import jakarta.servlet.http.HttpServletResponse; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameter; import static org.apache.catalina.startup.SimpleHttpClient.CRLF; import org.apache.catalina.core.StandardContext; import org.apache.catalina.startup.Tomcat; @RunWith(Parameterized.class) public class TestServletRequestParametersMultipartEncoded extends ServletRequestParametersBaseTest { @Parameterized.Parameters(name = "{index}: chunked[{0}]") public static Collection<Object[]> parameters() { List<Object[]> parameterSets = new ArrayList<>(); for (Boolean chunked : booleans) { parameterSets.add(new Object[] { chunked }); } return parameterSets; } @Parameter(0) public boolean chunked; @Test public void testBodyTooLarge() throws Exception { Tomcat tomcat = getTomcatInstance(); tomcat.getConnector().setMaxPostSize(50); // No file system docBase required StandardContext ctx = (StandardContext) getProgrammaticRootContext(); ctx.setAllowCasualMultipartParsing(true); // Map the test Servlet ParameterParsingServlet parameterParsingServlet = new ParameterParsingServlet(); Tomcat.addServlet(ctx, "parameterParsingServlet", parameterParsingServlet); ctx.addServletMappingDecoded("/", "parameterParsingServlet"); tomcat.start(); TestParameterClient client = new TestParameterClient(); client.setPort(getPort()); if (chunked) { // @formatter:off client.setRequest(new String[] { "POST / HTTP/1.1" + CRLF + "Host: localhost:" + getPort() + CRLF + "Connection: close" + CRLF + "Transfer-Encoding: chunked" + CRLF + "Content-Type: multipart/form-data; boundary=AaBbCc" + CRLF + CRLF + "3f" + CRLF + "--AaBbCc" + CRLF + "Content-Disposition: form-data; name=\"var1\"" + CRLF + CRLF + "val1" + CRLF + CRLF + "3f" + CRLF + "--AaBbCc" + CRLF + "Content-Disposition: form-data; name=\"var2\"" + CRLF + CRLF + "val2" + CRLF + CRLF + "3f" + CRLF + "--AaBbCc" + CRLF + "Content-Disposition: form-data; name=\"var3\"" + CRLF + CRLF + "val3" + CRLF + CRLF + "0a" + CRLF + "--AaBbCc--" + CRLF + "0" + CRLF + CRLF }); // @formatter:on } else { // @formatter:off client.setRequest(new String[] { "POST / HTTP/1.1" + CRLF + "Host: localhost:" + getPort() + CRLF + "Connection: close" + CRLF + "Content-Length: 199" + CRLF + "Content-Type: multipart/form-data; boundary=AaBbCc" + CRLF + CRLF + "--AaBbCc" + CRLF + "Content-Disposition: form-data; name=\"var1\"" + CRLF + CRLF + "val1" + CRLF + "--AaBbCc" + CRLF + "Content-Disposition: form-data; name=\"var2\"" + CRLF + CRLF + "val2" + CRLF + "--AaBbCc" + CRLF + "Content-Disposition: form-data; name=\"var3\"" + CRLF + CRLF + "val3" + CRLF + "--AaBbCc--" }); // @formatter:on } client.setResponseBodyEncoding(StandardCharsets.UTF_8); client.connect(); client.processRequest(); Assert.assertEquals(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE, client.getStatusCode()); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
26.27
Copyrights

      
    
Holders

      
    
Authors

      
    
License detections License expression License expression SPDX
apache_2_0-4bde3f57-78aa-4201-96bf-531cba09e7de apache-2.0 Apache-2.0
URL Start line End line
http://www.apache.org/licenses/LICENSE-2.0 9 9