Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom error response. #1278

Open
GrzegorzRussek opened this issue Oct 7, 2022 · 2 comments
Open

Custom error response. #1278

GrzegorzRussek opened this issue Oct 7, 2022 · 2 comments

Comments

@GrzegorzRussek
Copy link

Is your feature request related to a problem? Please describe.
I'm unable to add simple web page informing about service and it's purpose.

Describe the solution you'd like
I't would be best to provide ability to override response when handshake not in place. (no connection upgrade)
I would suggest adding Exception argument to generateHttpResponseDueToError method and:

Either make generateHttpResponseDueToError protected or invoke from it like this to get error code page:

    protected String getErrorCodeDescriptionPage(int errorCode, Exception exception) {
    }

Describe alternatives you've considered
I tried to approach this by using refection to tinker with generateHttpResponseDueToError metod in WebSocketImpl class with no working results.

Additional context
None

@marci4
Copy link
Collaborator

marci4 commented Oct 8, 2022

To be honest, I dont wanna make this a webserver.

For normal websocket requests there is #977

@GrzegorzRussek
Copy link
Author

I'm aware of that and approve, but ability to tell client via for example QR code, scan this with our app to connect would be life saver.

It would be great to be able to hook up by inheritance/inspector or some other form to the point where library throws html page.

Java is very protective about it's private members so I did not found any way to hook up to that logic (except for inspecting outgoing buffers, but that slows things down dramatically).

Another probably simple and elegant solution would be to pass down to some listener http connections that don't want to upgrade to WebSocket. In that case you do not handle that request therefore you will not make a WebServer out of this library, but if someone chose to then he has ability to handle those requests on it's own.

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

No branches or pull requests

2 participants