From 865217859faa59de5dd46b43af13646b8696df5c Mon Sep 17 00:00:00 2001 From: Anton Bachin Date: Tue, 14 Dec 2021 19:37:41 +0300 Subject: [PATCH] Cut request_from_http from dream-pure This completes an initial version of the refactoring mentioned in #8. --- src/middleware/server.ml | 4 +++- src/pure/dream_pure.mli | 10 ---------- src/pure/inmost.ml | 23 ----------------------- 3 files changed, 3 insertions(+), 34 deletions(-) diff --git a/src/middleware/server.ml b/src/middleware/server.ml index f99aa8ee..81ac76f1 100644 --- a/src/middleware/server.ml +++ b/src/middleware/server.ml @@ -46,7 +46,9 @@ let with_https https request = (* TODO Eventually remove Dream.request_from_http as all of its functionality is moved here. *) let request ~client ~method_ ~target ~https ~version ~headers server_stream = - Dream.request_from_http ~method_ ~target ~version ~headers server_stream + (* TODO Use pre-allocated streams. *) + let client_stream = Dream.Stream.(stream no_reader no_writer) in + Dream.request ~method_ ~target ~version ~headers client_stream server_stream |> with_client client |> with_https https diff --git a/src/pure/dream_pure.mli b/src/pure/dream_pure.mli index 3e6b63c7..90ebd85d 100644 --- a/src/pure/dream_pure.mli +++ b/src/pure/dream_pure.mli @@ -322,16 +322,6 @@ val is_websocket : response -> (websocket -> unit promise) option -val request_from_http : - method_:method_ -> - target:string -> - version:int * int -> - headers:(string * string) list -> - stream -> - request - - - module Formats : sig val html_escape : string -> string diff --git a/src/pure/inmost.ml b/src/pure/inmost.ml index c1a00d6d..cb3968d7 100644 --- a/src/pure/inmost.ml +++ b/src/pure/inmost.ml @@ -259,29 +259,6 @@ let with_local key value message = let fold_locals f initial message = fold_scope f initial message.locals -let request_from_http - ~method_ - ~target - ~version - ~headers - body = - - let rec request = { - specific = { - method_; - target; - request_version = version; - }; - headers; - client_stream = Stream.(stream no_reader no_writer); - server_stream = body; - locals = Scope.empty; - first = request; (* TODO LATER What OCaml version is required for this? *) - last = ref request; - } in - - request - let request ?method_ ?(target = "/")