Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,20 @@ public static boolean checkContains(final String s1, final String s2) {
}
return s1.contains(s2);
}

/**
* Check if the first String contains() the second String and ignore case. This method
* returns false if the first string is null.
* @param s1 String to be checked if it contains
* @param s2 String to check for
* @return true, iff s1.contains(s2), otherwise false
*/
public static boolean checkContainsIgnoreCase(final String s1, final String s2) {
if (s1 == null) {
return false;
}
return s1.toLowerCase().contains(s2.toLowerCase());
}

/**
* Check if the first String startsWith() the second String. This method
Expand Down Expand Up @@ -467,8 +481,8 @@ private void shakeHands() throws IOException {
handshakeComplete = checkStartsWith(requestLine, "GET /")
&& checkContains(requestLine, "HTTP/")
&& req.get("Host") != null
&& checkContains(req.get("Upgrade"), "websocket")
&& checkContains(req.get("Connection"), "Upgrade")
&& checkContainsIgnoreCase(req.get("Upgrade"), "websocket")
&& checkContainsIgnoreCase(req.get("Connection"), "Upgrade")
&& "13".equals(req.get("Sec-WebSocket-Version"))
&& req.get("Sec-WebSocket-Key") != null;
String nonce = req.get("Sec-WebSocket-Key");
Expand Down