if (options.insertHttpVersionIfMissing()) { version = HttpVersion.HTTP_1_1; } else {
if (options.insertHttpVersionIfMissing()) { version = HttpVersion.HTTP_1_1; } else {
private RequestLine buildRequestLine(String requestLine) { if (requestLine.isEmpty()) { throw new InvalidHttpRequest("No content", 0); } String[] parts = requestLine.split("\\s"); if (parts.length == 2 || parts.length == 3) { String method = parts[0]; OptionalInt illegalIndex = FieldValues.indexOfNotAllowedInTokens(method); if (illegalIndex.isPresent()) { throw new InvalidHttpRequest("Invalid method name: illegal character at index " + illegalIndex.getAsInt(), 1); } URI uri = parseUri(parts[1]); HttpVersion httpVersion = options.insertHttpVersionIfMissing() ? HttpVersion.HTTP_1_1 : null; if (parts.length == 3) try { httpVersion = HttpVersion.parse(parts[2]); } catch (IllegalArgumentException e) { throw new InvalidHttpRequest("Invalid HTTP version", 1); } if (httpVersion == null) { throw new InvalidHttpRequest("Missing HTTP version", 1); } return new RequestLine(method, uri, httpVersion); } else { throw new InvalidHttpRequest("Invalid request line", 1); } }
private RequestLine buildRequestLine(String requestLine) { if (requestLine.isEmpty()) { throw new InvalidHttpRequest("No content", 0); } String[] parts = requestLine.split("\\s"); if (parts.length == 2 || parts.length == 3) { String method = parts[0]; OptionalInt illegalIndex = FieldValues.indexOfNotAllowedInTokens(method); if (illegalIndex.isPresent()) { throw new InvalidHttpRequest("Invalid method name: illegal character at index " + illegalIndex.getAsInt(), 1); } URI uri = parseUri(parts[1]); HttpVersion httpVersion = options.insertHttpVersionIfMissing() ? HttpVersion.HTTP_1_1 : null; if (parts.length == 3) try { httpVersion = HttpVersion.parse(parts[2]); } catch (IllegalArgumentException e) { throw new InvalidHttpRequest("Invalid HTTP version", 1); } if (httpVersion == null) { throw new InvalidHttpRequest("Missing HTTP version", 1); } return new RequestLine(method, uri, httpVersion); } else { throw new InvalidHttpRequest("Invalid request line", 1); } }