From 8755512719bd2ab50f0f897610975eea78bfcc60 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 8 Jun 2021 05:36:13 -0400 Subject: [PATCH] Make livereload websocket headers case insensitive Update livereload `Connection` handling code so that websocket headers are no longer case sensitive. See gh-26813 --- .../springframework/boot/devtools/livereload/Connection.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java index 21cdd21119c6..0a62bd03778e 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/livereload/Connection.java @@ -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"; @@ -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")) {