Describe what you would like to know or do
I'm denying clients which aren't providing all neccessary information and would like to set a custom Response Header field right here, is there a way for that? So that I can provide an error message, what is missing :)
Describe the solution you'd considered
I tried to put a HttpStatusMessage in the Builder´, which didn't work 👀
@Override
public ServerHandshakeBuilder onWebsocketHandshakeReceivedAsServer(WebSocket conn, Draft draft,
ClientHandshake request) throws InvalidDataException {
ServerHandshakeBuilder builder = super
.onWebsocketHandshakeReceivedAsServer(conn, draft, request);
int success = 0;
for (int i = 0; i <= 10; i++) {
String key = Core.getConfiguration().config().getString("socket.authenticator." + i + ".key");
String value = Core.getConfiguration().config().getString("socket.authenticator." + i + ".value");
if (key == null || value == null) continue;
if (!request.hasFieldValue(key)) continue;
if (request.getFieldValue(key).equals(value)) {
success++;
}
}
if (success != 11) {
// HERE I WANT TO SET A CUSTOM HTTP RESPONSE HEADER :)
throw new InvalidDataException(CloseFrame.POLICY_VALIDATION, "Not accepted");
}
return builder;
}
Describe what you would like to know or do I'm denying clients which aren't providing all neccessary information and would like to set a custom Response Header field right here, is there a way for that? So that I can provide an error message, what is missing :)
Describe the solution you'd considered I tried to put a HttpStatusMessage in the Builder´, which didn't work 👀