Commits

Nikhil Marathe committed 9784af0

Implemented bulk reply handler

Comments (0)

Files changed (1)

     (list message (length (r 2)))))
 
 (define (redis:handle-bulk-reply r)
-  (list (r 2) (length (r 2))))
+  (letn ((parts (parse (r 2) redis:CRLF)) ; $n\r\n.*\r\n
+        (reply-len (int (1 (parts 0)))))  ;<-^
+    (begin 
+      (if (= -1 reply-len)
+        (list '() (+ (length (parts 0)) (length (parts 1)) (length redis:CRLF))) ; length of $-1 + remnant
+        (begin
+          (if (<= reply-len (length (parts 1))) ; if we don't need to read more
+                (begin
+                  (letn ((replystring (0 reply-len (parts 1))) ; the .* part on the next line onwards
+                        (read-len (+ (length (parts 0))
+                                    reply-len
+                                    (* 2 (length redis:CRLF))))) ; 2 times because \r\n on each line
+                    (list replystring read-len)))
+            (redis:read r)))))))
 
 (define (redis:handle-error r)
   (throw-error (1 (chop (r 2) 2))))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.