Nikhil Marathe avatar Nikhil Marathe committed dea0a84

Fixed handle-bulk-reply. The keys aren't separated by \r\n. So using parse won't work. Instead
split manually at the front and the back. This problem was revealed by calling
INFO. INFO returns a \r\n separated list, which should be returned as a single bulk reply.

Comments (0)

Files changed (1)

     (list message (length (r 2)))))
 
 (define (redis:handle-bulk-reply r)
-  (letn ((parts (parse (r 2) redis:CRLF)) ; $n\r\n.*\r\n
-        (reply-len (int (1 (parts 0)))))  ;<-^
+  (letn ( (indx (find redis:CRLF (r 2)))
+          (reply-len (int (1 indx (r 2))))
+          ; the below line means
+          ; clip message from end of $<n>\r\n to howmuchever <n> is plus \r\n
+          (message ((+ indx (length redis:CRLF)) (+ reply-len (length redis:CRLF)) (r 2))) )
     (case reply-len
-      (-1 (list "" (+ (length (parts 0)) (length (parts 1)) (length redis:CRLF)))) ; length of $-1 + remnant
+      (-1 (list "" (+ (length "$-1") (length message) (length redis:CRLF)))) ; length of $-1 + remnant
       (true (begin
-          (if (<= reply-len (length (parts 1))) ; if we don't need to read more
+          (if (<= reply-len (- (length message) (length redis:CRLF))) ; 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)))
+              (let (read-len (+ indx
+                                reply-len
+                                (* 2 (length redis:CRLF)))) ; 2 times because \r\n on each line
+                (list (0 (- 0 (length redis:CRLF)) message) read-len)))
             (redis:read r)))))))
 
 (define (redis:handle-multi-bulk-reply r)
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.