Skip to content

Commit

Permalink
Make livereload websocket headers case insensitive
Browse files Browse the repository at this point in the history
Update livereload `Connection` handling code so that websocket headers
are no longer case sensitive.

See gh-26813
  • Loading branch information
francislavoie authored and philwebb committed Jun 15, 2021
1 parent a1e279f commit 8755512
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Connection {

private static final Log logger = LogFactory.getLog(Connection.class);

private static final Pattern WEBSOCKET_KEY_PATTERN = Pattern.compile("^Sec-WebSocket-Key:(.*)$", Pattern.MULTILINE);
private static final Pattern WEBSOCKET_KEY_PATTERN = Pattern.compile("^Sec-WebSocket-Key:(.*)$", Pattern.MULTILINE | Pattern.CASE_INSENSITIVE);

public static final String WEBSOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";

Expand Down Expand Up @@ -77,7 +77,7 @@ class Connection {
* @throws Exception in case of errors
*/
void run() throws Exception {
if (this.header.contains("Upgrade: websocket") && this.header.contains("Sec-WebSocket-Version: 13")) {
if (this.header.contains("Upgrade: websocket") && this.header.toLowerCase().contains("sec-websocket-version: 13")) {
runWebSocket();
}
if (this.header.contains("GET /livereload.js")) {
Expand Down

0 comments on commit 8755512

Please sign in to comment.