denoland / std

The Deno Standard Library
https://jsr.io/@std
MIT License
3.18k stars 623 forks source link

feat req: add enums for WebSocket status #5436

Open lowlighter opened 3 months ago

lowlighter commented 3 months ago

Is your feature request related to a problem? Please describe.

The Websocket.close accept two args, an exit code and a reason, similar to http code and status text. This is defined by https://www.rfc-editor.org/rfc/rfc6455.html#section-7.4.1

Like what is currently provided for @std/http, it'd be nice to have a "human-readable" enum of defined code.

Only thing is that I don't think there's a "standard naming", but this could be inferred by the description in the rfc, or try to match the already defined http status

Describe the solution you'd like

Something similar to STATUS_CODE and STATUS_TEXT from @std/http

Describe alternatives you've considered

iuioiua commented 3 months ago

This seems like it could be useful. A couple of thoughts:

  1. To be explicit, we could add this to @std/http/status.
  2. We should document the fact that status texts are defined by us, and not the RFC.
lowlighter commented 2 months ago

Linking #5755 if it ever occurs

lino-levan commented 2 months ago

If #5755 happens, we should put this under the ws module.