ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/catalina/connector/TestCoyoteInputStream.java

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

      
    
Rootfs path

      
    
Size
2702 (2.6 KB)
MD5
bde565471fc8335bdc2b46dc88e402b2
SHA1
fe6f4d60d585624455e6d939ea3902e1c290f2fc
SHA256
70212657049145ac50acfe4f5737edf9f0d2e1feae341ee50bfd8d6da0332689
SHA512

      
    
SHA1_git
b27fbda7cf7d4c6385de320abdce7cab0c2e473b
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestCoyoteInputStream.java | 2.6 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 org.apache.catalina.connector; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.junit.Assert; import org.junit.Test; import org.apache.catalina.Context; import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.TomcatBaseTest; import org.apache.tomcat.util.buf.ByteChunk; public class TestCoyoteInputStream extends TomcatBaseTest { @Test public void testReadWithByteBuffer() throws Exception { Tomcat tomcat = getTomcatInstance(); Context root = tomcat.addContext("", TEMP_DIR); Tomcat.addServlet(root, "testServlet", new TestServlet()); root.addServletMappingDecoded("/", "testServlet"); tomcat.start(); ByteChunk bc = new ByteChunk(); String requestBody = "HelloWorld"; int rc = postUrl(requestBody.getBytes(StandardCharsets.UTF_8), "http://localhost:" + getPort() + "/", bc, null); Assert.assertEquals(HttpServletResponse.SC_OK, rc); Assert.assertTrue(requestBody.equals(bc.toString())); } private static final class TestServlet extends HttpServlet { private static final long serialVersionUID = 1L; @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { CoyoteInputStream is = (CoyoteInputStream) req.getInputStream(); ByteBuffer buffer = ByteBuffer.allocate(256); is.read(buffer); CoyoteOutputStream os = (CoyoteOutputStream) resp.getOutputStream(); os.write(buffer); } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
40.48
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