Anonymous avatar Anonymous committed ead696d Draft

read_0xA -> read_eol (CR? LF)

Comments (0)

Files changed (1)

dumbstreaming_it.ml

     ;
 
     value read_space = read_the_char '\x20'
-      and read_x0A = read_the_char '\x0A'
+      and read_eol =
+        I.peek >>= (fun
+        [ None -> ds_error "expected EOL (\\r?\\n), found EOF"
+        | Some '\r' -> I.junk
+        | _ -> I.return ()
+        ])
+        >>= fun () ->
+        I.peek >>= fun
+        [ None -> ds_error "expected EOL (\\n), found EOF"
+        | Some '\n' -> I.junk
+        | Some c -> ds_error "expected EOL (\\n), found %C" c
+        ]
     ;
 
 
        =
         match (lens, combine_it) with
         [ ([], _) ->
-           read_x0A >>= fun () ->
+           read_eol >>= fun () ->
            I.joinI (I.return combine_it)
         | ([len :: lens], (I.IE_done _ | I.IE_cont (Some _) _)) ->
             I.drop len >>= fun () ->
-            read_x0A >>= fun () ->
+            read_eol >>= fun () ->
             read_data_lens ~combine_it ~lens ~piecenumber:(piecenumber + 1)
         | ([len :: lens], I.IE_cont None k) ->
             let this_piece_it : I.iteratee char 'i = get_piece_it
               ~totalsize ~piecenumber ~piecesize:len ~totalcount in
             (I.joinI & I.take len this_piece_it) >>= fun this_piece_res ->
-            read_x0A >>= fun () ->
+            read_eol >>= fun () ->
 
             I.lift (I.feedI k (I.chunk_of this_piece_res))
               >>= fun combine_it ->
                       count lengths_count
         else
         let () = assert (count = List.length lengths) in
-        read_x0A >>= fun () ->
+        read_eol >>= fun () ->
         read_data_gen ~totalsize:packet_length ~lens:lengths
 
       in
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.