guix: Use guile-3.0.
[8sync.git] / 8sync / systems / websocket / server.scm
index 97645bb8ef3490a0b5b6f0e06c4b235b1e252925..11704d477e61a5051afdb2c24c103d360a4c4086 100644 (file)
@@ -1,5 +1,7 @@
 ;;; guile-websocket --- WebSocket client/server
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
+;;; Copyright © 2017 Christopher Allan Webber <cwebber@dustycloud.org>
+;;; Copyright © 2020,2021 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of guile-websocket.
 ;;;
@@ -69,8 +71,7 @@ string."
   ((ws-send websocket-server-send))
   (upgrade-paths #:init-value `(("websocket" .
                                  ,(wrap-apply websocket-client-loop)))
-                 #:allocation #:each-subclass
-                 #:accessor .upgrade-paths)
+                 #:allocation #:each-subclass)
 
   (gen-client-id #:init-thunk make-simple-counter)
 
@@ -133,7 +134,9 @@ called for each complete message that is received."
       (let ((frame (read-frame-maybe)))
         (cond
          ;; EOF - port is closed.
-         ((not frame)
+         ;; @@: Sometimes the eof object appears here as opposed to
+         ;;   at lookahead, but I'm not sure why
+         ((or (not frame) (eof-object? frame))
           (close-down))
          ;; Per section 5.4, control frames may appear interspersed
          ;; along with a fragmented message.
@@ -154,7 +157,8 @@ called for each complete message that is received."
          ((first-fragment-frame? frame) ; begin accumulating fragments
           (loop (list frame) (frame-type frame)))
          ((final-fragment-frame? frame) ; concatenate all fragments
-          (handle-data-frame type (frame-concatenate (reverse fragments)))
+          (handle-data-frame type (frame-concatenate
+                                   (reverse (cons frame fragments))))
           (loop '() #f))
          ((fragment-frame? frame) ; add a fragment
           (loop (cons frame fragments) type))