ttomcat-1778514358873.zip-extract/apache-tomcat-11.0.18-src/test/org/apache/coyote/http2/TestStream.java

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

      
    
Rootfs path

      
    
Size
5020 (4.9 KB)
MD5
d1ffe0632cebe196130739ce4f8c0fe8
SHA1
38bf05dd3596e3d6ad8e45e6b0da90b1a0bdd273
SHA256
c59cbd57c2ac0163e78da07d44d7651f23a30d456f5b2f65f47059270679c4f2
SHA512

      
    
SHA1_git
4afb07f8988d2d54227cc5897383e02912b1b2d8
Is binary

      
    
Is text
True
Is archive

      
    
Is media

      
    
Is legal

      
    
Is manifest

      
    
Is readme

      
    
Is top level

      
    
Is key file

      
    
TestStream.java | 4.9 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.coyote.http2; import java.io.IOException; import java.nio.ByteBuffer; 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 trailers.ResponseTrailers; public class TestStream extends Http2TestBase { /* * https://bz.apache.org/bugzilla/show_bug.cgi?id=61120 */ @Test public void testPathParam() throws Exception { enableHttp2(); Tomcat tomcat = getTomcatInstance(); Context ctxt = getProgrammaticRootContext(); Tomcat.addServlet(ctxt, "simple", new SimpleServlet()); ctxt.addServletMappingDecoded("/simple", "simple"); Tomcat.addServlet(ctxt, "pathparam", new PathParam()); ctxt.addServletMappingDecoded("/pathparam", "pathparam"); tomcat.start(); openClientConnection(); doHttpUpgrade(); sendClientPreface(); validateHttp2InitialResponse(); byte[] frameHeader = new byte[9]; ByteBuffer headersPayload = ByteBuffer.allocate(128); buildGetRequest(frameHeader, headersPayload, null, 3, "/pathparam;jsessionid=" + PathParam.EXPECTED_SESSION_ID); writeFrame(frameHeader, headersPayload); readSimpleGetResponse(); Assert.assertEquals("3-HeadersStart " + "3-Header-[:status]-[200] " + "3-Header-[content-type]-[text/plain;charset=UTF-8] " + "3-Header-[content-length]-[2] " + "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT] " + "3-HeadersEnd " + "3-Body-2 " + "3-EndOfStream ", output.getTrace()); } @Test public void testResponseTrailerFields() throws Exception { enableHttp2(); Tomcat tomcat = getTomcatInstance(); Context ctxt = getProgrammaticRootContext(); Tomcat.addServlet(ctxt, "simple", new SimpleServlet()); ctxt.addServletMappingDecoded("/simple", "simple"); Tomcat.addServlet(ctxt, "trailers", new ResponseTrailers()); ctxt.addServletMappingDecoded("/trailers", "trailers"); tomcat.start(); openClientConnection(); doHttpUpgrade(); sendClientPreface(); validateHttp2InitialResponse(); byte[] frameHeader = new byte[9]; ByteBuffer headersPayload = ByteBuffer.allocate(128); buildGetRequest(frameHeader, headersPayload, null, 3, "/trailers"); writeFrame(frameHeader, headersPayload); // Headers parser.readFrame(); // Body parser.readFrame(); // Trailers parser.readFrame(); Assert.assertEquals( "3-HeadersStart " + "3-Header-[:status]-[200] " + "3-Header-[content-type]-[text/plain;charset=UTF-8] " + "3-Header-[content-length]-[44] " + "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT] " + "3-HeadersEnd " + "3-Body-44 " + "3-HeadersStart " + "3-Header-[x-trailer-2]-[Trailer value two] " + "3-Header-[x-trailer-1]-[Trailer value one] " + "3-HeadersEnd " + "3-EndOfStream ", output.getTrace()); } private static final class PathParam extends HttpServlet { private static final long serialVersionUID = 1L; public static final String EXPECTED_SESSION_ID = "0123456789ABCDEF"; @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/plain"); response.setCharacterEncoding("UTF-8"); if (EXPECTED_SESSION_ID.equals(request.getRequestedSessionId())) { response.getWriter().write("OK"); } else { response.getWriter().write("FAIL"); } } } }
Detected license expression
apache-2.0
Detected license expression (SPDX)
Apache-2.0
Percentage of license text
25.11
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
https://bz.apache.org/bugzilla/show_bug.cgi?id=61120 39 39