unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Nala Ginrut <nalaginrut@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Re: Support Websocket status code
Date: Mon, 29 Jul 2019 14:57:13 +0800	[thread overview]
Message-ID: <CAPjoZofg=9mbNx6EkFb+f8K=Bugvu6+VSb549u7dn8u_=KJnVg@mail.gmail.com> (raw)
In-Reply-To: <CAPjoZoe3XVoVTwzpg5qviBra50k4Wq4_05-dhA2fNhBRcf3wAg@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 812 bytes --]

Here is a patch to add necessary status code, and avoid checking failure
when building response.
Based on branch stable-2.2

Thanks!


On Fri, Jul 26, 2019 at 2:06 PM Nala Ginrut <nalaginrut@gmail.com> wrote:

> Hi folks!
> The current response builder will reject status code less than 600:
> -------------------------------code-------------------------
>  ((not (and (non-negative-integer? code) (< code 600)))
>   (bad-response "Bad code: ~a" code))
> ---------------------------------------------------------------
>
> However, Websocket specific status code is larger than 1000.
> This breaks Artanis Websocket handler to return 500, so that the client
> has no way to detect the actual problem.
>
> Is there any plan to support it?
> Or maybe someone is just waiting for a patch? ;-)
>
> Best regards.
>
>

[-- Attachment #1.2: Type: text/html, Size: 1304 bytes --]

[-- Attachment #2: 0001-Add-Websocket-status-code.patch --]
[-- Type: text/x-patch, Size: 1733 bytes --]

From 757bf959e364485f105a977c3f971b9252dfb4db Mon Sep 17 00:00:00 2001
From: Nala Ginrut <mulei@gnu.org>
Date: Mon, 29 Jul 2019 14:55:37 +0800
Subject: [PATCH] Add Websocket status code

---
 module/web/response.scm | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/module/web/response.scm b/module/web/response.scm
index 06e1c6dc1..77a856a48 100644
--- a/module/web/response.scm
+++ b/module/web/response.scm
@@ -118,7 +118,7 @@ the headers are each run through their respective validators."
               (non-negative-integer? (car version))
               (non-negative-integer? (cdr version))))
     (bad-response "Bad version: ~a" version))
-   ((not (and (non-negative-integer? code) (< code 600)))
+   ((not (and (non-negative-integer? code) (<= code 1015)))
     (bad-response "Bad code: ~a" code))
    ((and reason-phrase (not (string? reason-phrase)))
     (bad-response "Bad reason phrase" reason-phrase))
@@ -167,7 +167,20 @@ the headers are each run through their respective validators."
     (502 . "Bad Gateway")
     (503 . "Service Unavailable")
     (504 . "Gateway Timeout")
-    (505 . "HTTP Version Not Supported")))
+    (505 . "HTTP Version Not Supported")
+    (1000 . "Normal Closure")
+    (1001 . "Going Away")
+    (1002 . "Protocol error")
+    (1003 . "Unsupported Data")
+    (1004 . "Reserved")
+    (1005 . "No status received")
+    (1006 . "Abnormal Closure")
+    (1007 . "Invalid frame payload data")
+    (1008 . "Policy Violation")
+    (1009 . "Message Too Big")
+    (1010 . "Mandatory Ext.")
+    (1011 . "Internet Server Error")
+    (1015 . "TLS handshake")))
 
 (define (code->reason-phrase code)
   (or (assv-ref *reason-phrases* code)
-- 
2.20.1


  reply	other threads:[~2019-07-29  6:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-26  6:06 Support Websocket status code Nala Ginrut
2019-07-29  6:57 ` Nala Ginrut [this message]
2019-08-07  6:52 ` Mark H Weaver
2019-08-07 11:39   ` Nala Ginrut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPjoZofg=9mbNx6EkFb+f8K=Bugvu6+VSb549u7dn8u_=KJnVg@mail.gmail.com' \
    --to=nalaginrut@gmail.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).