|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | + * contributor license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright ownership. |
| 5 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | + * (the "License"); you may not use this file except in compliance with |
| 7 | + * the License. You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +package org.apache.coyote.http2; |
| 19 | + |
| 20 | +import org.junit.Assert; |
| 21 | +import org.junit.Test; |
| 22 | + |
| 23 | +import org.apache.catalina.connector.Request; |
| 24 | + |
| 25 | +public class TestHttp2RequestParameters extends Http2TestBase { |
| 26 | + /** |
| 27 | + * Test case for https://bz.apache.org/bugzilla/show_bug.cgi?id=69918 POST parameters are not returned from a call |
| 28 | + * to any of the {@link Request} getParameterXXX() methods if the request is HTTP/2 and the |
| 29 | + * content-length header is not set. |
| 30 | + */ |
| 31 | + @Test |
| 32 | + public void testBug69918() throws Exception { |
| 33 | + http2Connect(); |
| 34 | + |
| 35 | + sendParameterPostRequest(3, null, "a=1&b=2", -1, false); |
| 36 | + output.setTraceBody(true); |
| 37 | + |
| 38 | + boolean foundBody = false; |
| 39 | + while (parser.readFrame()) { |
| 40 | + String trace = output.getTrace(); |
| 41 | + if (trace.contains("3-Body-2")) { |
| 42 | + foundBody = true; |
| 43 | + } else if (trace.contains("3-Body-0")) { |
| 44 | + Assert.fail("Parameter count was 0. Trace: " + trace); |
| 45 | + } |
| 46 | + if (trace.contains("3-EndOfStream")) { |
| 47 | + break; |
| 48 | + } |
| 49 | + } |
| 50 | + Assert.assertTrue("Parameter count should be 2, trace: " + output.getTrace(), foundBody); |
| 51 | + } |
| 52 | +} |
0 commit comments