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 <nalagin...@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.
>
>
From 757bf959e364485f105a977c3f971b9252dfb4db Mon Sep 17 00:00:00 2001
From: Nala Ginrut <mu...@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 via email to