Update websocket close codes to comply with RFC
This commit is contained in:
parent
bc5fd5d441
commit
4c543e6f06
|
@ -74,7 +74,7 @@ public class WebsocketController implements WebSocketListener, PubSubListener {
|
||||||
if (usernames == null || usernames.length == 0 ||
|
if (usernames == null || usernames.length == 0 ||
|
||||||
passwords == null || passwords.length == 0)
|
passwords == null || passwords.length == 0)
|
||||||
{
|
{
|
||||||
session.close(new CloseStatus(401, "Unauthorized"));
|
session.close(new CloseStatus(4001, "Unauthorized"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ public class WebsocketController implements WebSocketListener, PubSubListener {
|
||||||
Optional<Account> account = accountAuthenticator.authenticate(credentials);
|
Optional<Account> account = accountAuthenticator.authenticate(credentials);
|
||||||
|
|
||||||
if (!account.isPresent()) {
|
if (!account.isPresent()) {
|
||||||
session.close(new CloseStatus(401, "Unauthorized"));
|
session.close(new CloseStatus(4001, "Unauthorized"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ public class WebsocketController implements WebSocketListener, PubSubListener {
|
||||||
|
|
||||||
handleQueryDatabase();
|
handleQueryDatabase();
|
||||||
} catch (AuthenticationException e) {
|
} catch (AuthenticationException e) {
|
||||||
try { session.close(500, "Server Error");} catch (IOException e1) {}
|
try { session.close(1011, "Server Error");} catch (IOException e1) {}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
logger.info("Abrupt session close.");
|
logger.info("Abrupt session close.");
|
||||||
}
|
}
|
||||||
|
@ -112,11 +112,11 @@ public class WebsocketController implements WebSocketListener, PubSubListener {
|
||||||
handleMessageAck(body);
|
handleMessageAck(body);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
close(new CloseStatus(410, "Unknown Type"));
|
close(new CloseStatus(1008, "Unknown Type"));
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.debug("Parse", e);
|
logger.debug("Parse", e);
|
||||||
close(new CloseStatus(410, "Badly Formatted"));
|
close(new CloseStatus(1008, "Badly Formatted"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue