2323import java .net .SocketTimeoutException ;
2424import java .security .MessageDigest ;
2525import java .security .NoSuchAlgorithmException ;
26- import java .util .Locale ;
2726import java .util .regex .Matcher ;
2827import java .util .regex .Pattern ;
2928
@@ -44,7 +43,8 @@ class Connection {
4443
4544 private static final Log logger = LogFactory .getLog (Connection .class );
4645
47- private static final Pattern WEBSOCKET_KEY_PATTERN = Pattern .compile ("^sec-websocket-key:(.*)$" , Pattern .MULTILINE );
46+ private static final Pattern WEBSOCKET_KEY_PATTERN = Pattern .compile ("^sec-websocket-key:(.*)$" ,
47+ Pattern .MULTILINE | Pattern .CASE_INSENSITIVE );
4848
4949 public static final String WEBSOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" ;
5050
@@ -73,18 +73,19 @@ class Connection {
7373 this .outputStream = new ConnectionOutputStream (outputStream );
7474 String header = this .inputStream .readHeader ();
7575 logger .debug (LogMessage .format ("Established livereload connection [%s]" , header ));
76- this .header = header . toLowerCase ( Locale . ENGLISH ) ;
76+ this .header = header ;
7777 }
7878
7979 /**
8080 * Run the connection.
8181 * @throws Exception in case of errors
8282 */
8383 void run () throws Exception {
84- if (this .header .contains ("upgrade: websocket" ) && this .header .contains ("sec-websocket-version: 13" )) {
84+ String lowerCaseHeader = this .header .toLowerCase ();
85+ if (lowerCaseHeader .contains ("upgrade: websocket" ) && lowerCaseHeader .contains ("sec-websocket-version: 13" )) {
8586 runWebSocket ();
8687 }
87- if (this . header .contains ("get /livereload.js" )) {
88+ if (lowerCaseHeader .contains ("get /livereload.js" )) {
8889 this .outputStream .writeHttp (getClass ().getResourceAsStream ("livereload.js" ), "text/javascript" );
8990 }
9091 }
0 commit comments