Skip to content

Custom error response. #1278

Open
Open

Description

@GrzegorzRussek

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

Activity

  1. marci4 commented on Oct 8, 2022

    @marci4
    Collaborator

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

    For normal websocket requests there is #977

  2. GrzegorzRussek commented on Oct 12, 2022

    @GrzegorzRussek
    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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions