mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -05:00
format
This commit is contained in:
parent
0fbfd9df43
commit
de9760d786
14 changed files with 82 additions and 74 deletions
|
|
@ -27,8 +27,8 @@ open struct
|
|||
slice.len <- 0
|
||||
end
|
||||
|
||||
let create ?(masksigpipe = not (Sys.win32)) ?max_connections ?(timeout = 0.0) ?buf_size
|
||||
?(get_time_s = Unix.gettimeofday)
|
||||
let create ?(masksigpipe = not Sys.win32) ?max_connections ?(timeout = 0.0)
|
||||
?buf_size ?(get_time_s = Unix.gettimeofday)
|
||||
?(new_thread = fun f -> ignore (Thread.create f () : Thread.t))
|
||||
?(addr = "127.0.0.1") ?(port = 8080) ?sock ?middlewares () : t =
|
||||
let max_connections = get_max_connection_ ?max_connections () in
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
(public_name tiny_httpd_camlzip)
|
||||
(synopsis "A wrapper around camlzip to bring compression to Tiny_httpd")
|
||||
(flags :standard -open Tiny_httpd_core -safe-string -warn-error -a+8)
|
||||
(libraries (re_export tiny_httpd.core)
|
||||
(re_export iostream-camlzip)
|
||||
camlzip))
|
||||
(libraries
|
||||
(re_export tiny_httpd.core)
|
||||
(re_export iostream-camlzip)
|
||||
camlzip))
|
||||
|
|
|
|||
|
|
@ -1,12 +1,17 @@
|
|||
|
||||
(library
|
||||
(name tiny_httpd_core)
|
||||
(public_name tiny_httpd.core)
|
||||
(private_modules parse_ common_)
|
||||
(libraries threads seq hmap iostream
|
||||
(select log.ml from
|
||||
(logs -> log.logs.ml)
|
||||
(-> log.default.ml))))
|
||||
(name tiny_httpd_core)
|
||||
(public_name tiny_httpd.core)
|
||||
(private_modules parse_ common_)
|
||||
(libraries
|
||||
threads
|
||||
seq
|
||||
hmap
|
||||
iostream
|
||||
(select
|
||||
log.ml
|
||||
from
|
||||
(logs -> log.logs.ml)
|
||||
(-> log.default.ml))))
|
||||
|
||||
(rule
|
||||
(targets Atomic_.ml)
|
||||
|
|
|
|||
18
src/dune
18
src/dune
|
|
@ -1,8 +1,12 @@
|
|||
(library
|
||||
(name tiny_httpd)
|
||||
(public_name tiny_httpd)
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(libraries threads seq unix hmap
|
||||
(re_export tiny_httpd.core)
|
||||
(re_export tiny_httpd.html)
|
||||
(re_export tiny_httpd.unix)))
|
||||
(name tiny_httpd)
|
||||
(public_name tiny_httpd)
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(libraries
|
||||
threads
|
||||
seq
|
||||
unix
|
||||
hmap
|
||||
(re_export tiny_httpd.core)
|
||||
(re_export tiny_httpd.html)
|
||||
(re_export tiny_httpd.unix)))
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
|
||||
|
||||
(library
|
||||
(name tiny_httpd_html)
|
||||
(public_name tiny_httpd.html)
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(libraries seq tiny_httpd.core))
|
||||
(name tiny_httpd_html)
|
||||
(public_name tiny_httpd.html)
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(libraries seq tiny_httpd.core))
|
||||
|
||||
(rule
|
||||
(targets html_.ml)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
(library
|
||||
(name tiny_httpd_prometheus)
|
||||
(public_name tiny_httpd.prometheus)
|
||||
|
|
@ -7,7 +5,10 @@
|
|||
(private_modules common_p_ time_)
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(libraries
|
||||
(re_export tiny_httpd.core) unix
|
||||
(select time_.ml from
|
||||
(re_export tiny_httpd.core)
|
||||
unix
|
||||
(select
|
||||
time_.ml
|
||||
from
|
||||
(mtime mtime.clock.os -> time_.mtime.ml)
|
||||
(-> time_.default.ml))))
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
|
||||
(library
|
||||
(name tiny_httpd_unix)
|
||||
(public_name tiny_httpd.unix)
|
||||
(synopsis "Backend based on Unix and blocking IOs for Tiny_httpd")
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(private_modules mime_)
|
||||
(libraries tiny_httpd.core tiny_httpd.html unix
|
||||
(select mime_.ml from
|
||||
(magic-mime -> mime_.magic.ml)
|
||||
( -> mime_.dummy.ml))
|
||||
))
|
||||
(name tiny_httpd_unix)
|
||||
(public_name tiny_httpd.unix)
|
||||
(synopsis "Backend based on Unix and blocking IOs for Tiny_httpd")
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(private_modules mime_)
|
||||
(libraries
|
||||
tiny_httpd.core
|
||||
tiny_httpd.html
|
||||
unix
|
||||
(select
|
||||
mime_.ml
|
||||
from
|
||||
(magic-mime -> mime_.magic.ml)
|
||||
(-> mime_.dummy.ml))))
|
||||
|
|
|
|||
|
|
@ -1,2 +1 @@
|
|||
|
||||
val mime_of_path : string -> string
|
||||
val mime_of_path : string -> string
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ module Unix_tcp_server_ = struct
|
|||
{
|
||||
IO.TCP_server.serve =
|
||||
(fun ~after_init ~handle () : unit ->
|
||||
if self.masksigpipe && not (Sys.win32) then
|
||||
if self.masksigpipe && not Sys.win32 then
|
||||
ignore (Unix.sigprocmask Unix.SIG_BLOCK [ Sys.sigpipe ] : _ list);
|
||||
let sock, should_bind =
|
||||
match self.sock with
|
||||
|
|
@ -83,7 +83,7 @@ module Unix_tcp_server_ = struct
|
|||
(Thread.id @@ Thread.self ())
|
||||
(Util.show_sockaddr client_addr));
|
||||
|
||||
if self.masksigpipe && not (Sys.win32) then
|
||||
if self.masksigpipe && not Sys.win32 then
|
||||
ignore (Unix.sigprocmask Unix.SIG_BLOCK [ Sys.sigpipe ] : _ list);
|
||||
Unix.set_nonblock client_sock;
|
||||
Unix.setsockopt client_sock Unix.TCP_NODELAY true;
|
||||
|
|
@ -113,7 +113,7 @@ module Unix_tcp_server_ = struct
|
|||
Sem.acquire 1 self.sem_max_connections;
|
||||
(* Block INT/HUP while cloning to avoid children handling them.
|
||||
When thread gets them, our Unix.accept raises neatly. *)
|
||||
if not (Sys.win32) then
|
||||
if not Sys.win32 then
|
||||
ignore Unix.(sigprocmask SIG_BLOCK Sys.[ sigint; sighup ]);
|
||||
self.new_thread (fun () ->
|
||||
try
|
||||
|
|
@ -137,7 +137,7 @@ module Unix_tcp_server_ = struct
|
|||
(Util.show_sockaddr client_addr)
|
||||
(Printexc.to_string e)
|
||||
(Printexc.raw_backtrace_to_string bt)));
|
||||
if not (Sys.win32) then
|
||||
if not Sys.win32 then
|
||||
ignore Unix.(sigprocmask SIG_UNBLOCK Sys.[ sigint; sighup ])
|
||||
| exception Unix.Unix_error ((Unix.EAGAIN | Unix.EWOULDBLOCK), _, _)
|
||||
->
|
||||
|
|
|
|||
23
src/ws/dune
23
src/ws/dune
|
|
@ -1,12 +1,13 @@
|
|||
|
||||
(library
|
||||
(name tiny_httpd_ws)
|
||||
(public_name tiny_httpd.ws)
|
||||
(synopsis "Websockets for tiny_httpd")
|
||||
(private_modules common_ws_ utils_)
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(foreign_stubs
|
||||
(language c)
|
||||
(names tiny_httpd_ws_stubs)
|
||||
(flags :standard -std=c99 -fPIC -O2))
|
||||
(libraries (re_export tiny_httpd.core) threads))
|
||||
(name tiny_httpd_ws)
|
||||
(public_name tiny_httpd.ws)
|
||||
(synopsis "Websockets for tiny_httpd")
|
||||
(private_modules common_ws_ utils_)
|
||||
(flags :standard -open Tiny_httpd_core)
|
||||
(foreign_stubs
|
||||
(language c)
|
||||
(names tiny_httpd_ws_stubs)
|
||||
(flags :standard -std=c99 -fPIC -O2))
|
||||
(libraries
|
||||
(re_export tiny_httpd.core)
|
||||
threads))
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
(test
|
||||
(name t_prom)
|
||||
(libraries tiny_httpd.prometheus))
|
||||
(name t_prom)
|
||||
(libraries tiny_httpd.prometheus))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
(tests
|
||||
(names t_util t_buf t_server t_io)
|
||||
(package tiny_httpd)
|
||||
(libraries tiny_httpd.core qcheck-core qcheck-core.runner test_util))
|
||||
(names t_util t_buf t_server t_io)
|
||||
(package tiny_httpd)
|
||||
(libraries tiny_httpd.core qcheck-core qcheck-core.runner test_util))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
(library
|
||||
(name test_util)
|
||||
(modules test_util)
|
||||
(libraries logs qcheck-core qcheck-core.runner))
|
||||
(name test_util)
|
||||
(modules test_util)
|
||||
(libraries logs qcheck-core qcheck-core.runner))
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
(tests
|
||||
(names t_ws t_ws_q)
|
||||
(package tiny_httpd)
|
||||
(deps masked.data)
|
||||
(libraries tiny_httpd.ws qcheck-core qcheck-core.runner test_util))
|
||||
(names t_ws t_ws_q)
|
||||
(package tiny_httpd)
|
||||
(deps masked.data)
|
||||
(libraries tiny_httpd.ws qcheck-core qcheck-core.runner test_util))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue