This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit cc9e398c9f3fdb5dd5ae82f6973de923bd0bb067 Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Aug 21 16:33:38 2020 +0100 Improve validation of expected response --- .../apache/coyote/http2/TestCancelledUpload.java | 67 +++++++++++++++++----- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/test/org/apache/coyote/http2/TestCancelledUpload.java b/test/org/apache/coyote/http2/TestCancelledUpload.java index a89dc55..f9691ca 100644 --- a/test/org/apache/coyote/http2/TestCancelledUpload.java +++ b/test/org/apache/coyote/http2/TestCancelledUpload.java @@ -62,29 +62,66 @@ public class TestCancelledUpload extends Http2TestBase { // Trailers writeFrame(trailerFrameHeader, trailerPayload); - // The actual response depends on timing issues. Particularly how much - // data is transferred in StreamInputBuffer inBuffer to outBuffer on the - // first read. - while (output.getTrace().length() == 0) { - try { - parser.readFrame(true); - if ("3-RST-[3]\n".equals(output.getTrace())) { - output.clearTrace(); - } - } catch (IOException ioe) { - // Might not be any further frames after the reset - break; - } + // The Server will process the request on a separate thread to the + // incoming frames. + // The request processing thread will: + // - read up to 128 bytes of request body + // (and issue a window update for bytes read) + // - write a 403 response with no response body + // The connection processing thread will: + // - read the request body until the flow control window is exhausted + // - reset the stream if further DATA frames are received + parser.readFrame(true); + + // If reset is first frame received end test here + if (output.getTrace().startsWith("3-RST-[3]\\n")) { + return; + } + + // Validate any WindowSize frames (always arrive in pairs) + while (output.getTrace().startsWith("0-WindowSize-[")) { + String trace = output.getTrace(); + int size = Integer.parseInt(trace.substring(14, trace.length() - 2)); + output.clearTrace(); + parser.readFrame(true); + Assert.assertEquals("3-WindowSize-[" + size + "]\n", output.getTrace()); + output.clearTrace(); + parser.readFrame(true); } - if (output.getTrace().startsWith("0-WindowSize-[")) { + // Check for reset and exit if found + if (output.getTrace().startsWith("3-RST-[3]\n")) { + return; + } + + // Not window update, not reset, must be the response + parser.readFrame(true); + Assert.assertEquals("3-HeadersStart\n" + + "3-Header-[:status]-[403]\n" + + "3-Header-[content-length]-[0]\n" + + "3-Header-[date]-[Wed, 11 Nov 2015 19:18:42 GMT]\n" + + "3-HeadersEnd\n" + + "3-Body-0\n" + + "3-EndOfStream\n", + output.getTrace()); + output.clearTrace(); + + // There must be a reset. There may be some WindowSize frames + parser.readFrame(true); + + // Validate any WindowSize frames (always arrive in pairs) + while (output.getTrace().startsWith("0-WindowSize-[")) { String trace = output.getTrace(); int size = Integer.parseInt(trace.substring(14, trace.length() - 2)); output.clearTrace(); - // Window updates always come in pairs parser.readFrame(true); Assert.assertEquals("3-WindowSize-[" + size + "]\n", output.getTrace()); } + + // This should be the reset + Assert.assertEquals("3-RST-[3]\n", output.getTrace()); + + // If there are any more frames after this, ignore them } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org