From f03012072c096580bcd7b753515614aa6f95f89d Mon Sep 17 00:00:00 2001 From: Stanislav Artemkin Date: Thu, 23 Apr 2015 00:02:02 +0400 Subject: [PATCH] Limited read buffer size in Async backend to 32K. --- async/cohttp_async_io.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/async/cohttp_async_io.ml b/async/cohttp_async_io.ml index 6490545d6c..ee2fae9855 100644 --- a/async/cohttp_async_io.ml +++ b/async/cohttp_async_io.ml @@ -49,14 +49,19 @@ let read_line = |`Eof -> eprintf "<<>| function - | `Ok len' -> String.sub buf 0 len' + | `Ok len' -> + if len' = len then buf else String.sub buf 0 len' | `Eof -> "" let read_exactly ic len = - let buf = String.create len in + let buf, len = create_buf len in Reader.really_read ic ~pos:0 ~len buf >>| function |`Ok -> Some buf