mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-07 11:45:36 -05:00
Compare commits
7 commits
10ccdf52d0
...
246de4a74c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
246de4a74c | ||
|
|
169c19b679 | ||
|
|
711312141a | ||
|
|
42f8ed40af | ||
|
|
b1dfdf1f39 | ||
|
|
365889557c | ||
|
|
2a7e597643 |
6 changed files with 8 additions and 34 deletions
|
|
@ -26,6 +26,11 @@ let atomic_before_412 =
|
||||||
|
|
||||||
let atomic_after_412 = {|include Atomic|}
|
let atomic_after_412 = {|include Atomic|}
|
||||||
|
|
||||||
|
let write_file file s =
|
||||||
|
let oc = open_out file in
|
||||||
|
output_string oc s;
|
||||||
|
close_out oc
|
||||||
|
|
||||||
let () =
|
let () =
|
||||||
let version = Scanf.sscanf Sys.ocaml_version "%d.%d.%s" (fun x y _ -> x, y) in
|
let version = Scanf.sscanf Sys.ocaml_version "%d.%d.%s" (fun x y _ -> x, y) in
|
||||||
print_endline
|
print_endline
|
||||||
|
|
|
||||||
|
|
@ -91,34 +91,3 @@ module Private_ = struct
|
||||||
end
|
end
|
||||||
|
|
||||||
let pp out x = Format.pp_print_string out (to_string x)
|
let pp out x = Format.pp_print_string out (to_string x)
|
||||||
|
|
||||||
let rec to_url_rec : type b. Buffer.t -> (b, string) t -> b =
|
|
||||||
fun buf route ->
|
|
||||||
match route with
|
|
||||||
| Fire -> Buffer.contents buf
|
|
||||||
| Rest { url_encoded = _ } ->
|
|
||||||
fun str ->
|
|
||||||
Buffer.add_string buf str;
|
|
||||||
Buffer.contents buf
|
|
||||||
| Compose (comp, rest) ->
|
|
||||||
(match comp with
|
|
||||||
| Exact s ->
|
|
||||||
Buffer.add_string buf s;
|
|
||||||
Buffer.add_char buf '/';
|
|
||||||
to_url_rec buf rest
|
|
||||||
| Int ->
|
|
||||||
fun i ->
|
|
||||||
Printf.bprintf buf "%d/" i;
|
|
||||||
to_url_rec buf rest
|
|
||||||
| String ->
|
|
||||||
fun s ->
|
|
||||||
Printf.bprintf buf "%s/" s;
|
|
||||||
to_url_rec buf rest
|
|
||||||
| String_urlencoded ->
|
|
||||||
fun s ->
|
|
||||||
Printf.bprintf buf "%s/" (Util.percent_encode s);
|
|
||||||
to_url_rec buf rest)
|
|
||||||
|
|
||||||
let to_url (h : ('a, string) t) : 'a =
|
|
||||||
let buf = Buffer.create 16 in
|
|
||||||
to_url_rec buf h
|
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,6 @@ val to_string : _ t -> string
|
||||||
(** Print the route.
|
(** Print the route.
|
||||||
@since 0.7 *)
|
@since 0.7 *)
|
||||||
|
|
||||||
val to_url : ('a, string) t -> 'a
|
|
||||||
|
|
||||||
module Private_ : sig
|
module Private_ : sig
|
||||||
val eval : string list -> ('a, 'b) t -> 'a -> 'b option
|
val eval : string list -> ('a, 'b) t -> 'a -> 'b option
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ module Head_middleware = struct
|
||||||
type t = { handle: 'a. 'a Request.t -> 'a Request.t }
|
type t = { handle: 'a. 'a Request.t -> 'a Request.t }
|
||||||
|
|
||||||
let trivial = { handle = Fun.id }
|
let trivial = { handle = Fun.id }
|
||||||
|
let[@inline] apply (self : t) req = self.handle req
|
||||||
let[@inline] apply' req (self : t) = self.handle req
|
let[@inline] apply' req (self : t) = self.handle req
|
||||||
|
|
||||||
let to_middleware (self : t) : Middleware.t =
|
let to_middleware (self : t) : Middleware.t =
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
(* adapted from https://github.com/sindresorhus/html-tags (MIT licensed) *)
|
(* adapted from https://github.com/sindresorhus/html-tags (MIT licensed) *)
|
||||||
|
|
||||||
let pf = Printf.printf
|
let pf = Printf.printf
|
||||||
|
let spf = Printf.sprintf
|
||||||
|
|
||||||
let void =
|
let void =
|
||||||
[
|
[
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ CAMLprim value tiny_httpd_ws_apply_masking(value _mask_key, value _mask_offset,
|
||||||
CAMLparam5(_mask_key, _mask_offset, _buf, _offset, _len);
|
CAMLparam5(_mask_key, _mask_offset, _buf, _offset, _len);
|
||||||
|
|
||||||
char const *mask_key = String_val(_mask_key);
|
char const *mask_key = String_val(_mask_key);
|
||||||
unsigned char *buf = Bytes_val(_buf);
|
char *buf = Bytes_val(_buf);
|
||||||
intnat mask_offset = Int_val(_mask_offset);
|
intnat mask_offset = Int_val(_mask_offset);
|
||||||
intnat offset = Int_val(_offset);
|
intnat offset = Int_val(_offset);
|
||||||
intnat len = Int_val(_len);
|
intnat len = Int_val(_len);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue