Skip to content

Conversation

@barkyq
Copy link

@barkyq barkyq commented Feb 5, 2023

Hello Gobwas,

Thanks for the great package. I was hoping to add an option to "hijack" the upgrade process if a certain header was present, cancelling the upgrade negotiation and handing back control to the caller of "Upgrade," without writing anything to the "Conn."

My idea was to use status code "418" http.StatusTeapot, defined in https://www.rfc-editor.org/rfc/rfc2324 as a signal that the user wants to Hijack the handshake process.

This is to implement https://github.com/nostr-protocol/nips/blob/master/11.md in a project I am working on.

Sincerely,
Barky Q

@barkyq
Copy link
Author

barkyq commented Feb 19, 2023

changed the logic from the initial commit. now it is called escape hatch.

With this way, the upgrader can see all the non-ws headers and store any relevant information in the error pointer, which gets passed around to each call of OnHost and OnHeader.

@lets-build-an-ocean
Copy link

Relying on http.StatusTeapot (418) makes the project implicit rather than explicit. Future maintainers/users might not understand why 418 triggers special behavior without reading documentation carefully.

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

Labels

None yet

2 participants