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

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

      
    
Rootfs path

      
    
Size
3451 (3.4 KB)
MD5
499e7e0e6e70b7434e9323c81403b52e
SHA1
bd1b8e7d51e3a353d6b8b37ad19a39d95e9d1e59
SHA256
78c42ed0e325491f9fdbdb1600b662e41fe8d8da0bd8d8444cb613ecccec3b8a
SHA512

      
    
SHA1_git
b6fc75a4332855659455de45d435782da30eea57
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
ServletRequestParametersBaseTest.java | 3.4 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.io.IOException; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Enumeration; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.apache.catalina.startup.SimpleHttpClient; import org.apache.catalina.startup.TomcatBaseTest; public class ServletRequestParametersBaseTest extends TomcatBaseTest { protected Map<String,List<String>> parseReportedParameters(SimpleHttpClient client) { Map<String,List<String>> parameters = new LinkedHashMap<>(); if (client.isResponse200()) { // Response is written using " " so need to split on that. String[] lines = client.getResponseBody().split(" "); for (String line : lines) { // Every line should be name=value int equalsPos = line.indexOf('='); String name = line.substring(0, equalsPos); String value = line.substring(equalsPos + 1); List<String> values = parameters.computeIfAbsent(name, k -> new ArrayList<>()); values.add(value); } } return parameters; } protected static class ParameterParsingServlet extends HttpServlet { private static final long serialVersionUID = 1L; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/plain"); resp.setCharacterEncoding(StandardCharsets.UTF_8); PrintWriter pw = resp.getWriter(); Enumeration<String> names = req.getParameterNames(); while (names.hasMoreElements()) { String name = names.nextElement(); for (String value : req.getParameterValues(name)) { pw.print(name + "=" + value + ' '); } } } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { // Required parameter processing is the same as for GET doGet(req, resp); } } protected static class TestParameterClient extends SimpleHttpClient { @Override public boolean isResponseBodyOK() { return true; } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
34.0
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