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

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

      
    
Rootfs path

      
    
Size
4219 (4.1 KB)
MD5
4fbe1eb24d39f7b8b7d2dc780c8cae61
SHA1
a50060043fa00dd04d9bdfaf87fc2c47fec7cbc2
SHA256
f8d3545dfc8a4121014d7436510343b4c5d177870bdf95cdd8bf0045b629a6ac
SHA512

      
    
SHA1_git
db2ece1ab06c79e0680cfce87668442a3d40abcf
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestServletRequestParametersFormUrlEncoded.java | 4.1 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.SimpleHttpClient; import org.apache.catalina.startup.Tomcat; @RunWith(Parameterized.class) public class TestServletRequestParametersFormUrlEncoded 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(20); // No file system docBase required StandardContext ctx = (StandardContext) getProgrammaticRootContext(); // 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 + SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING + CRLF + "0a" + CRLF + "var1=val1&" + CRLF + "0a" + CRLF + "var2=val2&" + CRLF + "0a" + CRLF + "var3=val3&" + 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: 50" + CRLF + SimpleHttpClient.HTTP_HEADER_CONTENT_TYPE_FORM_URL_ENCODING + CRLF + "01234567890123456789012345678901234567890123456789" }); // @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
30.83
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