@@ -46,7 +46,7 @@ let create ?(buf_size = 64 * 1024) ?(out_buf_size = 8 * 1024) ~boundary ic : st
4646
4747type chunk = Delim | Eof | Read of int
4848
49- let [@ inline] min_len_ (self : st ) : int = 4 + String. length self.boundary
49+ let [@ inline] min_len_ (self : st ) : int = 2 + String. length self.boundary
5050
5151exception Found_boundary of int
5252
@@ -74,16 +74,14 @@ let rec read_chunk_ (self : st) buf i_buf len : chunk =
7474 ) else (
7575 try
7676 let i = ref 0 in
77- let end_pos = min len self.buf.len - 4 - String. length self.boundary in
77+ let end_pos = min len self.buf.len - 2 - String. length self.boundary in
7878 while ! i < = end_pos do
7979 if
80- Bytes. unsafe_get self.buf.bs ! i = '\r'
81- && Bytes. unsafe_get self.buf.bs (! i + 1 ) = '\n'
82- && Bytes. unsafe_get self.buf.bs (! i + 2 ) = '-'
83- && Bytes. unsafe_get self.buf.bs (! i + 3 ) = '-'
80+ Bytes. unsafe_get self.buf.bs ! i = '-'
81+ && Bytes. unsafe_get self.buf.bs (! i + 1 ) = '-'
8482 && Utils_. string_eq
8583 ~a: (Bytes. unsafe_to_string self.buf.bs)
86- ~a_start: (! i + 4 ) ~b: self.boundary
84+ ~a_start: (! i + 2 ) ~b: self.boundary
8785 ~len: (String. length self.boundary)
8886 then
8987 raise_notrace (Found_boundary ! i);
@@ -95,7 +93,7 @@ let rec read_chunk_ (self : st) buf i_buf len : chunk =
9593 Read n_read
9694 with
9795 | Found_boundary 0 ->
98- shift_left_ self.buf (4 + String. length self.boundary);
96+ shift_left_ self.buf (2 + String. length self.boundary);
9997 Delim
10098 | Found_boundary n ->
10199 let n_read = min n len in
@@ -191,7 +189,6 @@ and parse_headers_rec (self : st) acc : Headers.t =
191189 )
192190 | i ->
193191 let line = Bytes. sub_string self.buf_out.bs 0 i in
194- Printf. eprintf " parse header line %S\n %!" line;
195192 shift_left_ self.buf_out (i + 2 );
196193 if line = " " then
197194 List. rev acc
0 commit comments