MCPcopy Index your code
hub / github.com/apache/tomcat / prepareRequest

Method prepareRequest

java/org/apache/coyote/http2/Stream.java:168–213  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166
167
168 private void prepareRequest() {
169 if (coyoteRequest.scheme().isNull()) {
170 if (handler.getProtocol().getHttp11Protocol().isSSLEnabled()) {
171 coyoteRequest.scheme().setString("https");
172 } else {
173 coyoteRequest.scheme().setString("http");
174 }
175 }
176 MessageBytes hostValueMB = coyoteRequest.getMimeHeaders().getUniqueValue("host");
177 if (hostValueMB == null) {
178 throw new IllegalArgumentException();
179 }
180 // This processing expects bytes. Trigger a conversion if required.
181 hostValueMB.toBytes();
182 ByteChunk valueBC = hostValueMB.getByteChunk();
183 byte[] valueB = valueBC.getBytes();
184 int valueL = valueBC.getLength();
185 int valueS = valueBC.getStart();
186
187 int colonPos = Host.parse(hostValueMB);
188 if (colonPos != -1) {
189 int port = 0;
190 for (int i = colonPos + 1; i < valueL; i++) {
191 char c = (char) valueB[i + valueS];
192 if (c < '0' || c > '9') {
193 throw new IllegalArgumentException();
194 }
195 int digit = c - '0';
196 if (port > (Integer.MAX_VALUE - digit) / 10) {
197 throw new IllegalArgumentException();
198 }
199 port = port * 10 + digit;
200 }
201 coyoteRequest.setServerPort(port);
202
203 // Only need to copy the host name up to the :
204 valueL = colonPos;
205 }
206
207 // Extract the host name
208 char[] hostNameC = new char[valueL];
209 for (int i = 0; i < valueL; i++) {
210 hostNameC[i] = (char) valueB[i + valueS];
211 }
212 coyoteRequest.serverName().setChars(hostNameC, 0, valueL);
213 }
214
215
216 final void receiveReset(long errorCode) {

Callers 1

StreamMethod · 0.95

Calls 15

toBytesMethod · 0.95
getByteChunkMethod · 0.95
getBytesMethod · 0.95
parseMethod · 0.95
schemeMethod · 0.80
getHttp11ProtocolMethod · 0.80
getUniqueValueMethod · 0.80
serverNameMethod · 0.80
isNullMethod · 0.65
getProtocolMethod · 0.65
getLengthMethod · 0.65
isSSLEnabledMethod · 0.45

Tested by

no test coverage detected