Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse_form: add pase_form function to body modules #440

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions async/cohttp_async.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ module Body = struct
| `Pipe p -> `Pipe (Pipe.map p ~f)

let as_pipe t ~f = `Pipe (t |> to_pipe |> f)

let to_form t =
to_string t >>| Uri.query_of_encoded
end

module Client = struct
Expand Down
1 change: 1 addition & 0 deletions async/cohttp_async.mli
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Body : sig
val of_pipe : string Pipe.Reader.t -> t
val map : t -> f:(string -> string) -> t
val as_pipe : t -> f:(string Pipe.Reader.t -> string Pipe.Reader.t) -> t
val to_form : t -> (string * string list) list Deferred.t
end

module Client : sig
Expand Down
3 changes: 3 additions & 0 deletions lib/body.ml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,7 @@ let map f t =
| `String s -> `String (f s)
| `Strings sl -> `Strings (List.map f sl)

let to_form t =
Uri.query_of_encoded (to_string t)

(* TODO: maybe add a functor here that uses IO.S *)
1 change: 1 addition & 0 deletions lib/s.mli
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,5 @@ module type Body = sig
val of_string_list : string list -> t
val map : (string -> string) -> t -> t
val transfer_encoding : t -> Transfer.encoding
val to_form : t -> (string * string list) list
end
3 changes: 3 additions & 0 deletions lwt-core/cohttp_lwt_body.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,6 @@ let map f t =
match t with
| #Body.t as t -> (Body.map f t :> t)
| `Stream s -> `Stream (Lwt_stream.map f s)

let to_form t =
to_string t >|= Uri.query_of_encoded
1 change: 1 addition & 0 deletions lwt-core/cohttp_lwt_body.mli
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ val length : t -> (int64 * t) Lwt.t
val write_body : (string -> unit Lwt.t) -> t -> unit Lwt.t

val drain_body : t -> unit Lwt.t
val to_form : t -> (string * string list) list Lwt.t
4 changes: 2 additions & 2 deletions setup.ml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.4.5 *)

(* OASIS_START *)
(* DO NOT EDIT (digest: 30301e2efbaf4c256d48471e2910193c) *)
(* DO NOT EDIT (digest: f6c915ff5bdd9f1d40ce76bfa70d641f) *)
(*
Regenerated by OASIS v0.4.5
Visit http://oasis.forge.ocamlcore.org for more information and
Expand Down Expand Up @@ -8890,7 +8890,7 @@ let setup_t =
};
oasis_fn = Some "_oasis";
oasis_version = "0.4.5";
oasis_digest = Some "ܢ�E˵\003\130�\021%C:&";
oasis_digest = Some "\220\162\241E\203\181\003\130\208\021\190%C:&\178";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false
Expand Down