From 80528e073fee44f7e76b1962ba0c35d59425462d Mon Sep 17 00:00:00 2001 From: Rob Hoes Date: Thu, 17 Oct 2024 09:59:09 +0000 Subject: [PATCH] Remove unused Http_svr.Chunked module Signed-off-by: Rob Hoes --- ocaml/libs/http-lib/http_svr.ml | 72 -------------------------------- ocaml/libs/http-lib/http_svr.mli | 10 ----- 2 files changed, 82 deletions(-) diff --git a/ocaml/libs/http-lib/http_svr.ml b/ocaml/libs/http-lib/http_svr.ml index e04520d8567..d033fb7805f 100644 --- a/ocaml/libs/http-lib/http_svr.ml +++ b/ocaml/libs/http-lib/http_svr.ml @@ -713,78 +713,6 @@ let read_body ?limit req bio = else Buf_io.really_input_buf ~timeout:Buf_io.infinite_timeout bio length -module Chunked = struct - type t = { - mutable current_size: int - ; mutable current_offset: int - ; mutable read_headers: bool - ; bufio: Buf_io.t - } - - let of_bufio bufio = - {current_size= 0; current_offset= 0; bufio; read_headers= true} - - let rec read chunk size = - if chunk.read_headers = true then ( - (* first get the size, then get the data requested *) - let size = - Buf_io.input_line chunk.bufio - |> Bytes.to_string - |> String.trim - |> Printf.sprintf "0x%s" - |> int_of_string - in - chunk.current_size <- size ; - chunk.current_offset <- 0 ; - chunk.read_headers <- false - ) ; - (* read as many bytes from this chunk as possible *) - if chunk.current_size = 0 then - "" - else - let bytes_to_read = - min size (chunk.current_size - chunk.current_offset) - in - if bytes_to_read = 0 then - "" - else - let data = Bytes.make bytes_to_read '\000' in - Buf_io.really_input chunk.bufio data 0 bytes_to_read ; - (* now update the data structure: *) - if chunk.current_offset + bytes_to_read = chunk.current_size then ( - (* finished a chunk: get rid of the CRLF *) - let blank = Bytes.of_string "\000\000" in - Buf_io.really_input chunk.bufio blank 0 2 ; - if Bytes.to_string blank <> "\r\n" then - failwith "chunked encoding error" ; - chunk.read_headers <- true - ) else (* partway through a chunk. *) - chunk.current_offset <- chunk.current_offset + bytes_to_read ; - Bytes.unsafe_to_string data ^ read chunk (size - bytes_to_read) -end - -let read_chunked_encoding _req bio = - let rec next () = - let size = - Buf_io.input_line bio - (* Strictly speaking need to kill anything past an ';' if present *) - |> Bytes.to_string - |> String.trim - |> Printf.sprintf "0x%s" - |> int_of_string - in - if size = 0 then - Http.End - else - let chunk = Bytes.make size '\000' in - Buf_io.really_input bio chunk 0 size ; - (* Then get rid of the CRLF *) - let blank = Bytes.of_string "\000\000" in - Buf_io.really_input bio blank 0 2 ; - Http.Item (chunk, next) - in - next () - (* Helpers to determine the client of a call *) type protocol = Https | Http diff --git a/ocaml/libs/http-lib/http_svr.mli b/ocaml/libs/http-lib/http_svr.mli index d85ad28a2ec..52f6719dd0a 100644 --- a/ocaml/libs/http-lib/http_svr.mli +++ b/ocaml/libs/http-lib/http_svr.mli @@ -74,16 +74,6 @@ exception Socket_not_found val stop : socket -> unit -module Chunked : sig - type t - - val of_bufio : Buf_io.t -> t - - val read : t -> int -> string -end - -val read_chunked_encoding : Http.Request.t -> Buf_io.t -> bytes Http.ll - (* The rest of this interface needs to be deleted and replaced with Http.Response.* *) val response_fct :