Skip to content

Conversation

@mhabou
Copy link

@mhabou mhabou commented Apr 4, 2017

Add .toLowerCase() to req.get("Upgrade") and req.get("Connection") checks to support IE browsers

before this change i got this error

network error 12152 in IE browsers

Hope this commit help someone

…ecks to support IE browsers

before this change i got this error

network error 12152 in IE browsers

Hope this commit help someone
@blinkdog
Copy link
Owner

blinkdog commented Apr 4, 2017

Thank you for the PR @Dayssam.

Full disclosure: I don't have a Windows box, so I can't test this in IE myself. I rely upon you to know if it actually works or not. :-)

            && checkContains(req.get("Upgrade").toLowerCase(), "websocket")
            && checkContains(req.get("Connection").toLowerCase(), "Upgrade")

I do want to add this, but I'd rather do it like this:

            && checkContainsIgnoreCase(req.get("Upgrade"), "websocket")
            && checkContainsIgnoreCase(req.get("Connection"), "Upgrade")

req.get() in this context can return null if the request does not contain the specified header.

The checkContains() method checks and handles null values, so they aren't a problem in the existing code.

However, the code req.get("Upgrade").toLowerCase() will throw a NullPointerException if one tries to call toLowerCase() on a null return value from req.get().

This is why I'd think to make a checkContainsIgnoreCase which can guard against a null value and call toLowerCase() on the result if it exists.

I don't have time to do that right this second, but I'll take a look as soon as I can.
If you want to amend this PR with that suggestion, that'd be awesome.

Thanks again @Dayssam!

@mhabou
Copy link
Author

mhabou commented Apr 5, 2017

I created a new function checkContainsIgnoreCase to handle that

#5

Thank you very much

i have an other question

i'm using JAVA 6 , so i c'ant use java.nio.charset.StandardCharsets;

for the received message i got it char by char in http://www.websocket.org/echo.html

CONNECTED

SENT: Rock it with HTML5 WebSocket

RECEIVED: Data received: R

RECEIVED: Data received: o

RECEIVED: Data received: c

RECEIVED: Data received: k

RECEIVED: Data received:

RECEIVED: Data received: i

RECEIVED: Data received: t

RECEIVED: Data received:

RECEIVED: Data received: w

RECEIVED: Data received: i

RECEIVED: Data received: t

RECEIVED: Data received: h

RECEIVED: Data received:

RECEIVED: Data received: H

RECEIVED: Data received: T

RECEIVED: Data received: M

RECEIVED: Data received: L

RECEIVED: Data received: 5

RECEIVED: Data received:

RECEIVED: Data received: W

RECEIVED: Data received: e

RECEIVED: Data received: b

RECEIVED: Data received: S

RECEIVED: Data received: o

RECEIVED: Data received: c

RECEIVED: Data received: k

RECEIVED: Data received: e

RECEIVED: Data received: t
...

and in my example i got the first char of the received message WebSocket Rocks

Any idea ??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants