ws icon indicating copy to clipboard operation
ws copied to clipboard

added a Hijack Route for upgrade

Open barkyq opened this issue 3 years ago • 2 comments

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 avatar Feb 05 '23 22:02 barkyq

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.

barkyq avatar Feb 19 '23 00:02 barkyq