Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
c-cube committed Jun 18, 2024
1 parent 199bcff commit 3480816
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/core/IO.ml
Original file line number Diff line number Diff line change
Expand Up @@ -326,16 +326,12 @@ module Input = struct
let line = read_line_using ~buf:line_buf ic in
(* parse chunk length, ignore extensions *)
let chunk_size =
if String.trim line = "" then
0
else (
try
let off = ref 0 in
let n = Parse_.pos_hex line off in
n
with _ ->
raise (fail (spf "cannot read chunk size from line %S" line))
)
try
let off = ref 0 in
let n = Parse_.pos_hex line off in
n
with _ ->
raise (fail (spf "cannot read chunk size from line %S" line))
in
chunk_size
in
Expand All @@ -348,7 +344,13 @@ module Input = struct
method private refill (slice : Slice.t) : unit =
if !chunk_size = 0 && not !eof then (
chunk_size := read_next_chunk_len ();
if !chunk_size = 0 then eof := true (* stream is finished *)
if !chunk_size = 0 then
(* stream is finished, consume trailing \r\n *)
eof := true;
let line = read_line_using ~buf:line_buf ic in
if String.trim line <> "" then
raise
(fail (spf "expected \\r\\n to follow last chunk, got %S" line))
);
slice.off <- 0;
slice.len <- 0;
Expand Down

0 comments on commit 3480816

Please sign in to comment.