MCPcopy Create free account
hub / github.com/apache/tomcat / testEmptyWindow

Method testEmptyWindow

test/org/apache/coyote/http2/TestAsync.java:100–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

98
99
100 @Test
101 public void testEmptyWindow() throws Exception {
102 int blockCount = 8;
103
104 enableHttp2();
105
106 Tomcat tomcat = getTomcatInstance();
107
108 Context ctxt = getProgrammaticRootContext();
109 Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
110 ctxt.addServletMappingDecoded("/simple", "simple");
111 Wrapper w = Tomcat.addServlet(ctxt, "async", new AsyncServlet(blockCount, useNonContainerThreadForWrite));
112 w.setAsyncSupported(true);
113 ctxt.addServletMappingDecoded("/async", "async");
114 tomcat.start();
115
116 int startingWindowSize;
117
118 openClientConnection();
119 doHttpUpgrade();
120 sendClientPreface();
121 validateHttp2InitialResponse();
122
123 // Reset connection window size after initial response
124 sendWindowUpdate(0, SimpleServlet.CONTENT_LENGTH);
125
126 if (largeInitialWindow) {
127 startingWindowSize = ((1 << 17) - 1);
128 SettingValue sv = new SettingValue(Setting.INITIAL_WINDOW_SIZE.getId(), startingWindowSize);
129 sendSettings(0, false, sv);
130 // Test code assumes connection window and stream window size are the same at the start
131 sendWindowUpdate(0, startingWindowSize - ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE);
132 } else {
133 startingWindowSize = ConnectionSettingsBase.DEFAULT_INITIAL_WINDOW_SIZE;
134 }
135
136 byte[] frameHeader = new byte[9];
137 ByteBuffer headersPayload = ByteBuffer.allocate(128);
138 buildGetRequest(frameHeader, headersPayload, null, 3, "/async");
139 writeFrame(frameHeader, headersPayload);
140
141 if (connectionUnlimited) {
142 // Effectively unlimited for this test
143 sendWindowUpdate(0, blockCount * BLOCK_SIZE * 2);
144 }
145 if (streamUnlimited) {
146 // Effectively unlimited for this test
147 sendWindowUpdate(3, blockCount * BLOCK_SIZE * 2);
148 }
149
150 // Headers
151 parser.readFrame();
152 // Body
153
154 if (!connectionUnlimited || !streamUnlimited) {
155 while (output.getBytesRead() < startingWindowSize) {
156 parser.readFrame();
157 }

Callers

nothing calls this directly

Calls 15

addServletMethod · 0.95
setAsyncSupportedMethod · 0.95
startMethod · 0.95
enableHttp2Method · 0.80
getTomcatInstanceMethod · 0.80
openClientConnectionMethod · 0.80
sendClientPrefaceMethod · 0.80
sendWindowUpdateMethod · 0.80
sendSettingsMethod · 0.80
buildGetRequestMethod · 0.80

Tested by

no test coverage detected