()
| 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) { |
no test coverage detected