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

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

      
    
Rootfs path

      
    
Size
3187 (3.1 KB)
MD5
8cb834601773bae5e4df8d8a44229ee4
SHA1
2b9f818927c245cc974d2bfccf0eb6fd976b0fa6
SHA256
002b439d30d5d5e70a7d5931ccfe5290fe0f771f0723dc3cc48d4a600478a8ee
SHA512

      
    
SHA1_git
a86615d0c51dcc477f1c684aefab3a3095cfa653
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestServletRequestParameters.java | 3.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.net.SocketException; import java.nio.charset.StandardCharsets; import org.junit.Assert; import org.junit.Test; 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; public class TestServletRequestParameters extends ServletRequestParametersBaseTest { @Test public void testClientDisconnect() throws Exception { Tomcat tomcat = getTomcatInstance(); tomcat.getConnector().setMaxPostSize(20); Assert.assertTrue(tomcat.getConnector().setProperty("connectionTimeout", "1000")); // 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()); // @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 }); // @formatter:on client.setResponseBodyEncoding(StandardCharsets.UTF_8); client.connect(); // Incomplete request will look timeout reading body and behave like a client disconnect // What the client will see will vary by OS. Expect errors. try { client.processRequest(); } catch (SocketException e) { // Likely a connection reset. } // Connection should be closed by the server. // readLine() will receive an EOF reading the status line resulting in a null Assert.assertNull(client.getResponseLine()); } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
36.96
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